diff options
author | Dan Gohman <gohman@apple.com> | 2010-08-20 16:34:20 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-08-20 16:34:20 +0000 |
commit | 8df0e010469db2db5c641a50d9cfa74a5ffe68ea (patch) | |
tree | c539738e03c6c6735ed78d522e39b5bd75897126 /include/llvm | |
parent | 634d6619655f96628457d4b7126cd3a398f77631 (diff) | |
download | llvm-8df0e010469db2db5c641a50d9cfa74a5ffe68ea.tar.gz llvm-8df0e010469db2db5c641a50d9cfa74a5ffe68ea.tar.bz2 llvm-8df0e010469db2db5c641a50d9cfa74a5ffe68ea.tar.xz |
Move raw_ostream's Error flag into raw_fd_ostream, as that's the only
class which is using it.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111639 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Support/raw_ostream.h | 52 |
1 files changed, 27 insertions, 25 deletions
diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index 5c16fcd38c..df7f16e55b 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -58,10 +58,6 @@ private: ExternalBuffer } BufferMode; - /// Error This flag is true if an error of any kind has been detected. - /// - bool Error; - public: // color order matches ANSI escape sequence, don't change enum Colors { @@ -77,7 +73,7 @@ public: }; explicit raw_ostream(bool unbuffered=false) - : BufferMode(unbuffered ? Unbuffered : InternalBuffer), Error(false) { + : BufferMode(unbuffered ? Unbuffered : InternalBuffer) { // Start out ready to flush. OutBufStart = OutBufEnd = OutBufCur = 0; } @@ -87,21 +83,6 @@ public: /// tell - Return the current offset with the file. uint64_t tell() const { return current_pos() + GetNumBytesInBuffer(); } - /// has_error - Return the value of the flag in this raw_ostream indicating - /// whether an output error has been encountered. - /// This doesn't implicitly flush any pending output. - bool has_error() const { - return Error; - } - - /// clear_error - Set the flag read by has_error() to false. If the error - /// flag is set at the time when this raw_ostream's destructor is called, - /// report_fatal_error is called to report the error. Use clear_error() - /// after handling the error to avoid this behavior. - void clear_error() { - Error = false; - } - //===--------------------------------------------------------------------===// // Configuration Interface //===--------------------------------------------------------------------===// @@ -285,10 +266,6 @@ protected: /// underlying output mechanism. virtual size_t preferred_buffer_size() const; - /// error_detected - Set the flag indicating that an output error has - /// been encountered. - void error_detected() { Error = true; } - /// getBufferStart - Return the beginning of the current stream buffer, or 0 /// if the stream is unbuffered. const char *getBufferStart() const { return OutBufStart; } @@ -319,6 +296,11 @@ private: class raw_fd_ostream : public raw_ostream { int FD; bool ShouldClose; + + /// Error This flag is true if an error of any kind has been detected. + /// + bool Error; + uint64_t pos; /// write_impl - See raw_ostream::write_impl. @@ -331,6 +313,10 @@ class raw_fd_ostream : public raw_ostream { /// preferred_buffer_size - Determine an efficient buffer size. virtual size_t preferred_buffer_size() const; + /// error_detected - Set the flag indicating that an output error has + /// been encountered. + void error_detected() { Error = true; } + public: enum { @@ -365,7 +351,8 @@ public: /// ShouldClose is true, this closes the file when the stream is destroyed. raw_fd_ostream(int fd, bool shouldClose, bool unbuffered=false) : raw_ostream(unbuffered), FD(fd), - ShouldClose(shouldClose) {} + ShouldClose(shouldClose), + Error(false) {} ~raw_fd_ostream(); @@ -382,6 +369,21 @@ public: virtual raw_ostream &resetColor(); virtual bool is_displayed() const; + + /// has_error - Return the value of the flag in this raw_fd_ostream indicating + /// whether an output error has been encountered. + /// This doesn't implicitly flush any pending output. + bool has_error() const { + return Error; + } + + /// clear_error - Set the flag read by has_error() to false. If the error + /// flag is set at the time when this raw_ostream's destructor is called, + /// report_fatal_error is called to report the error. Use clear_error() + /// after handling the error to avoid this behavior. + void clear_error() { + Error = false; + } }; /// raw_stdout_ostream - This is a stream that always prints to stdout. |