diff options
author | Daniel Dunbar <daniel@zuster.org> | 2009-03-10 16:21:55 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2009-03-10 16:21:55 +0000 |
commit | e77e434bc96f2935dcf337909c4009324fe24eaf (patch) | |
tree | d96bf6900b376b6efdb9138127a1a32422cf856c /include/llvm | |
parent | 7af924839140d185e4da9fa5f86a01163b0691c0 (diff) | |
download | external_llvm-e77e434bc96f2935dcf337909c4009324fe24eaf.zip external_llvm-e77e434bc96f2935dcf337909c4009324fe24eaf.tar.gz external_llvm-e77e434bc96f2935dcf337909c4009324fe24eaf.tar.bz2 |
PR3478: raw_ostream should not buffer stderr
- Add unbuffered flag to raw_ostream, forwarded by raw_fd_ostream and
used by raw_stderr_ostream.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@66545 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm')
-rw-r--r-- | include/llvm/Support/raw_ostream.h | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/include/llvm/Support/raw_ostream.h b/include/llvm/Support/raw_ostream.h index 84fef39..0f1bee3 100644 --- a/include/llvm/Support/raw_ostream.h +++ b/include/llvm/Support/raw_ostream.h @@ -32,8 +32,10 @@ namespace llvm { class raw_ostream { protected: char *OutBufStart, *OutBufEnd, *OutBufCur; + bool Unbuffered; + public: - raw_ostream() { + raw_ostream(bool unbuffered=false) : Unbuffered(unbuffered) { // Start out ready to flush. OutBufStart = OutBufEnd = OutBufCur = 0; } @@ -59,6 +61,16 @@ public: OutBufCur = OutBufStart; } + /// SetUnbuffered - Set the streams buffering status. When + /// unbuffered the stream will flush after every write. This routine + /// will also flush the buffer immediately when the stream is being + /// set to unbuffered. + void SetUnbuffered(bool unbuffered) { + Unbuffered = unbuffered; + if (Unbuffered) + flush(); + } + //===--------------------------------------------------------------------===// // Data Output Interface //===--------------------------------------------------------------------===// @@ -165,9 +177,11 @@ public: raw_fd_ostream(const char *Filename, bool Binary, std::string &ErrorInfo); /// raw_fd_ostream ctor - FD is the file descriptor that this writes to. If - /// ShouldClose is true, this closes the file when - raw_fd_ostream(int fd, bool shouldClose) : FD(fd), ShouldClose(shouldClose) {} - + /// 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) {} + ~raw_fd_ostream(); /// flush_impl - The is the piece of the class that is implemented by |