summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-08-18 20:09:59 +0000
committerDan Gohman <gohman@apple.com>2009-08-18 20:09:59 +0000
commit23f90c1d3aefa4bfacac04cd44153f775c4e6568 (patch)
tree11d4ca4b066f099350fb8ade71de2882d98b0e49
parentd882f4b6ffa7a449f6d61fac35db6ad59785c5ac (diff)
downloadbcm5719-llvm-23f90c1d3aefa4bfacac04cd44153f775c4e6568.tar.gz
bcm5719-llvm-23f90c1d3aefa4bfacac04cd44153f775c4e6568.zip
Fix a bug in raw_ostream::write(char) introduced by the change to
allow underlying stream classes to decline buffering. After calling SetBuffered(), re-check whether the stream is Unbuffered in order to handle the case where the underlying stream has declined buffering. llvm-svn: 79362
-rw-r--r--llvm/lib/Support/raw_ostream.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/Support/raw_ostream.cpp b/llvm/lib/Support/raw_ostream.cpp
index a91fe9b5364..0c1843c457c 100644
--- a/llvm/lib/Support/raw_ostream.cpp
+++ b/llvm/lib/Support/raw_ostream.cpp
@@ -187,10 +187,17 @@ raw_ostream &raw_ostream::write(unsigned char C) {
return *this;
}
- if (!OutBufStart)
- SetBuffered();
- else
+ if (OutBufStart)
flush_nonempty();
+ else {
+ SetBuffered();
+ // It's possible for the underlying stream to decline
+ // buffering, so check this condition again.
+ if (Unbuffered) {
+ write_impl(reinterpret_cast<char*>(&C), 1);
+ return *this;
+ }
+ }
}
*OutBufCur++ = C;
OpenPOWER on IntegriCloud