remove SectionFlags::Small: it is only used on Xcore, and we'll find
[oota-llvm.git] / include / llvm / Support / FormattedStream.h
index 1c50476a6315c77edeb0c222f402da48bf4c51e8..dc30cdb5fe70dc049c3e63b7581df5bda4e49c53 100644 (file)
@@ -76,20 +76,9 @@ namespace llvm
     /// so it doesn't want another layer of buffering to be happening
     /// underneath it.
     ///
-    /// \param Filename - The file to open. If this is "-" then the
-    /// stream will use stdout instead.
-    /// \param Binary - The file should be opened in binary mode on
-    /// platforms that support this distinction.
     formatted_raw_ostream(raw_ostream &Stream, bool Delete = false) 
-      : raw_ostream(), TheStream(&Stream), DeleteStream(Delete), Column(0) {
-      // This formatted_raw_ostream inherits from raw_ostream, so it'll do its
-      // own buffering, and it doesn't need or want TheStream to do another
-      // layer of buffering underneath. Resize the buffer to what TheStream
-      // had been using, and tell TheStream not to do its own buffering.
-      TheStream->flush();
-      if (size_t BufferSize = TheStream->GetNumBytesInBuffer())
-        SetBufferSize(BufferSize);
-      TheStream->SetUnbuffered();
+      : raw_ostream(), TheStream(0), DeleteStream(false), Column(0) {
+      setStream(Stream, Delete);
     }
     explicit formatted_raw_ostream()
       : raw_ostream(), TheStream(0), DeleteStream(false), Column(0) {}
@@ -100,10 +89,16 @@ namespace llvm
     }
     
     void setStream(raw_ostream &Stream, bool Delete = false) {
+      if (DeleteStream)
+        delete TheStream;
+
       TheStream = &Stream;
       DeleteStream = Delete;
 
-      // Avoid double-buffering, as above.
+      // This formatted_raw_ostream inherits from raw_ostream, so it'll do its
+      // own buffering, and it doesn't need or want TheStream to do another
+      // layer of buffering underneath. Resize the buffer to what TheStream
+      // had been using, and tell TheStream not to do its own buffering.
       TheStream->flush();
       if (size_t BufferSize = TheStream->GetNumBytesInBuffer())
         SetBufferSize(BufferSize);