aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/llvm12/include/llvm/Support/raw_ostream.h
diff options
context:
space:
mode:
authorshadchin <shadchin@yandex-team.ru>2022-02-10 16:44:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:44:39 +0300
commite9656aae26e0358d5378e5b63dcac5c8dbe0e4d0 (patch)
tree64175d5cadab313b3e7039ebaa06c5bc3295e274 /contrib/libs/llvm12/include/llvm/Support/raw_ostream.h
parent2598ef1d0aee359b4b6d5fdd1758916d5907d04f (diff)
downloadydb-e9656aae26e0358d5378e5b63dcac5c8dbe0e4d0.tar.gz
Restoring authorship annotation for <shadchin@yandex-team.ru>. Commit 2 of 2.
Diffstat (limited to 'contrib/libs/llvm12/include/llvm/Support/raw_ostream.h')
-rw-r--r--contrib/libs/llvm12/include/llvm/Support/raw_ostream.h212
1 files changed, 106 insertions, 106 deletions
diff --git a/contrib/libs/llvm12/include/llvm/Support/raw_ostream.h b/contrib/libs/llvm12/include/llvm/Support/raw_ostream.h
index 37dc103e5f..adacc8bb0a 100644
--- a/contrib/libs/llvm12/include/llvm/Support/raw_ostream.h
+++ b/contrib/libs/llvm12/include/llvm/Support/raw_ostream.h
@@ -22,9 +22,9 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/Support/DataTypes.h"
#include <cassert>
-#include <chrono>
+#include <chrono>
#include <cstddef>
#include <cstdint>
#include <cstring>
@@ -39,14 +39,14 @@ class format_object_base;
class FormattedString;
class FormattedNumber;
class FormattedBytes;
-template <class T> class LLVM_NODISCARD Expected;
+template <class T> class LLVM_NODISCARD Expected;
namespace sys {
namespace fs {
enum FileAccess : unsigned;
enum OpenFlags : unsigned;
enum CreationDisposition : unsigned;
-class FileLocker;
+class FileLocker;
} // end namespace fs
} // end namespace sys
@@ -55,16 +55,16 @@ class FileLocker;
/// buffered disciplines etc. It is a simple buffer that outputs
/// a chunk at a time.
class raw_ostream {
-public:
- // Class kinds to support LLVM-style RTTI.
- enum class OStreamKind {
- OK_OStream,
- OK_FDStream,
- };
-
+public:
+ // Class kinds to support LLVM-style RTTI.
+ enum class OStreamKind {
+ OK_OStream,
+ OK_FDStream,
+ };
+
private:
- OStreamKind Kind;
-
+ OStreamKind Kind;
+
/// The buffer is handled in such a way that the buffer is
/// uninitialized, unbuffered, or out of space when OutBufCur >=
/// OutBufEnd. Thus a single comparison suffices to determine if we
@@ -122,10 +122,10 @@ public:
static constexpr Colors SAVEDCOLOR = Colors::SAVEDCOLOR;
static constexpr Colors RESET = Colors::RESET;
- explicit raw_ostream(bool unbuffered = false,
- OStreamKind K = OStreamKind::OK_OStream)
- : Kind(K), BufferMode(unbuffered ? BufferKind::Unbuffered
- : BufferKind::InternalBuffer) {
+ explicit raw_ostream(bool unbuffered = false,
+ OStreamKind K = OStreamKind::OK_OStream)
+ : Kind(K), BufferMode(unbuffered ? BufferKind::Unbuffered
+ : BufferKind::InternalBuffer) {
// Start out ready to flush.
OutBufStart = OutBufEnd = OutBufCur = nullptr;
}
@@ -138,8 +138,8 @@ public:
/// tell - Return the current offset with the file.
uint64_t tell() const { return current_pos() + GetNumBytesInBuffer(); }
- OStreamKind get_kind() const { return Kind; }
-
+ OStreamKind get_kind() const { return Kind; }
+
//===--------------------------------------------------------------------===//
// Configuration Interface
//===--------------------------------------------------------------------===//
@@ -408,9 +408,9 @@ class raw_pwrite_stream : public raw_ostream {
void anchor() override;
public:
- explicit raw_pwrite_stream(bool Unbuffered = false,
- OStreamKind K = OStreamKind::OK_OStream)
- : raw_ostream(Unbuffered, K) {}
+ explicit raw_pwrite_stream(bool Unbuffered = false,
+ OStreamKind K = OStreamKind::OK_OStream)
+ : raw_ostream(Unbuffered, K) {}
void pwrite(const char *Ptr, size_t Size, uint64_t Offset) {
#ifndef NDEBUG
uint64_t Pos = tell();
@@ -433,7 +433,7 @@ class raw_fd_ostream : public raw_pwrite_stream {
int FD;
bool ShouldClose;
bool SupportsSeeking = false;
- mutable Optional<bool> HasColors;
+ mutable Optional<bool> HasColors;
#ifdef _WIN32
/// True if this fd refers to a Windows console device. Mintty and other
@@ -457,18 +457,18 @@ class raw_fd_ostream : public raw_pwrite_stream {
/// Determine an efficient buffer size.
size_t preferred_buffer_size() const override;
- void anchor() override;
-
-protected:
+ void anchor() override;
+
+protected:
/// Set the flag indicating that an output error has been encountered.
void error_detected(std::error_code EC) { this->EC = EC; }
- /// Return the file descriptor.
- int get_fd() const { return FD; }
+ /// Return the file descriptor.
+ int get_fd() const { return FD; }
+
+ // Update the file position by increasing \p Delta.
+ void inc_pos(uint64_t Delta) { pos += Delta; }
- // Update the file position by increasing \p Delta.
- void inc_pos(uint64_t Delta) { pos += Delta; }
-
public:
/// Open the specified file for writing. If an error occurs, information
/// about the error is put into EC, and the stream should be immediately
@@ -492,8 +492,8 @@ public:
/// FD is the file descriptor that this writes to. If ShouldClose is true,
/// this closes the file when the stream is destroyed. If FD is for stdout or
/// stderr, it will not be closed.
- raw_fd_ostream(int fd, bool shouldClose, bool unbuffered = false,
- OStreamKind K = OStreamKind::OK_OStream);
+ raw_fd_ostream(int fd, bool shouldClose, bool unbuffered = false,
+ OStreamKind K = OStreamKind::OK_OStream);
~raw_fd_ostream() override;
@@ -501,7 +501,7 @@ public:
/// fsync.
void close();
- bool supportsSeeking() const { return SupportsSeeking; }
+ bool supportsSeeking() const { return SupportsSeeking; }
/// Flushes the stream and repositions the underlying file descriptor position
/// to the offset specified from the beginning of the file.
@@ -529,38 +529,38 @@ public:
/// - from The Zen of Python, by Tim Peters
///
void clear_error() { EC = std::error_code(); }
-
- /// Locks the underlying file.
- ///
- /// @returns RAII object that releases the lock upon leaving the scope, if the
- /// locking was successful. Otherwise returns corresponding
- /// error code.
- ///
- /// The function blocks the current thread until the lock become available or
- /// error occurs.
- ///
- /// Possible use of this function may be as follows:
- ///
- /// @code{.cpp}
- /// if (auto L = stream.lock()) {
- /// // ... do action that require file to be locked.
- /// } else {
- /// handleAllErrors(std::move(L.takeError()), [&](ErrorInfoBase &EIB) {
- /// // ... handle lock error.
- /// });
- /// }
- /// @endcode
- LLVM_NODISCARD Expected<sys::fs::FileLocker> lock();
-
- /// Tries to lock the underlying file within the specified period.
- ///
- /// @returns RAII object that releases the lock upon leaving the scope, if the
- /// locking was successful. Otherwise returns corresponding
- /// error code.
- ///
- /// It is used as @ref lock.
- LLVM_NODISCARD
- Expected<sys::fs::FileLocker> tryLockFor(std::chrono::milliseconds Timeout);
+
+ /// Locks the underlying file.
+ ///
+ /// @returns RAII object that releases the lock upon leaving the scope, if the
+ /// locking was successful. Otherwise returns corresponding
+ /// error code.
+ ///
+ /// The function blocks the current thread until the lock become available or
+ /// error occurs.
+ ///
+ /// Possible use of this function may be as follows:
+ ///
+ /// @code{.cpp}
+ /// if (auto L = stream.lock()) {
+ /// // ... do action that require file to be locked.
+ /// } else {
+ /// handleAllErrors(std::move(L.takeError()), [&](ErrorInfoBase &EIB) {
+ /// // ... handle lock error.
+ /// });
+ /// }
+ /// @endcode
+ LLVM_NODISCARD Expected<sys::fs::FileLocker> lock();
+
+ /// Tries to lock the underlying file within the specified period.
+ ///
+ /// @returns RAII object that releases the lock upon leaving the scope, if the
+ /// locking was successful. Otherwise returns corresponding
+ /// error code.
+ ///
+ /// It is used as @ref lock.
+ LLVM_NODISCARD
+ Expected<sys::fs::FileLocker> tryLockFor(std::chrono::milliseconds Timeout);
};
/// This returns a reference to a raw_fd_ostream for standard output. Use it
@@ -578,34 +578,34 @@ raw_fd_ostream &errs();
raw_ostream &nulls();
//===----------------------------------------------------------------------===//
-// File Streams
-//===----------------------------------------------------------------------===//
-
-/// A raw_ostream of a file for reading/writing/seeking.
-///
-class raw_fd_stream : public raw_fd_ostream {
-public:
- /// Open the specified file for reading/writing/seeking. If an error occurs,
- /// information about the error is put into EC, and the stream should be
- /// immediately destroyed.
- raw_fd_stream(StringRef Filename, std::error_code &EC);
-
- /// This reads the \p Size bytes into a buffer pointed by \p Ptr.
- ///
- /// \param Ptr The start of the buffer to hold data to be read.
- ///
- /// \param Size The number of bytes to be read.
- ///
- /// On success, the number of bytes read is returned, and the file position is
- /// advanced by this number. On error, -1 is returned, use error() to get the
- /// error code.
- ssize_t read(char *Ptr, size_t Size);
-
- /// Check if \p OS is a pointer of type raw_fd_stream*.
- static bool classof(const raw_ostream *OS);
-};
-
-//===----------------------------------------------------------------------===//
+// File Streams
+//===----------------------------------------------------------------------===//
+
+/// A raw_ostream of a file for reading/writing/seeking.
+///
+class raw_fd_stream : public raw_fd_ostream {
+public:
+ /// Open the specified file for reading/writing/seeking. If an error occurs,
+ /// information about the error is put into EC, and the stream should be
+ /// immediately destroyed.
+ raw_fd_stream(StringRef Filename, std::error_code &EC);
+
+ /// This reads the \p Size bytes into a buffer pointed by \p Ptr.
+ ///
+ /// \param Ptr The start of the buffer to hold data to be read.
+ ///
+ /// \param Size The number of bytes to be read.
+ ///
+ /// On success, the number of bytes read is returned, and the file position is
+ /// advanced by this number. On error, -1 is returned, use error() to get the
+ /// error code.
+ ssize_t read(char *Ptr, size_t Size);
+
+ /// Check if \p OS is a pointer of type raw_fd_stream*.
+ static bool classof(const raw_ostream *OS);
+};
+
+//===----------------------------------------------------------------------===//
// Output Stream Adaptors
//===----------------------------------------------------------------------===//
@@ -694,18 +694,18 @@ public:
~buffer_ostream() override { OS << str(); }
};
-class buffer_unique_ostream : public raw_svector_ostream {
- std::unique_ptr<raw_ostream> OS;
- SmallVector<char, 0> Buffer;
-
- virtual void anchor() override;
-
-public:
- buffer_unique_ostream(std::unique_ptr<raw_ostream> OS)
- : raw_svector_ostream(Buffer), OS(std::move(OS)) {}
- ~buffer_unique_ostream() override { *OS << str(); }
-};
-
+class buffer_unique_ostream : public raw_svector_ostream {
+ std::unique_ptr<raw_ostream> OS;
+ SmallVector<char, 0> Buffer;
+
+ virtual void anchor() override;
+
+public:
+ buffer_unique_ostream(std::unique_ptr<raw_ostream> OS)
+ : raw_svector_ostream(Buffer), OS(std::move(OS)) {}
+ ~buffer_unique_ostream() override { *OS << str(); }
+};
+
} // end namespace llvm
#endif // LLVM_SUPPORT_RAW_OSTREAM_H