[llvm-commits] [llvm] r77255 - in /llvm/trunk: include/llvm/Support/raw_ostream.h lib/Support/raw_ostream.cpp

Dan Gohman gohman at apple.com
Mon Jul 27 14:46:02 PDT 2009


Author: djg
Date: Mon Jul 27 16:46:02 2009
New Revision: 77255

URL: http://llvm.org/viewvc/llvm-project?rev=77255&view=rev
Log:
Make raw_null_ostream flush its buffer in its destructor, so that
it conforms to the assertion added in r77245. This fixes a failure
in qa_override.c in clang's testsuite.

Modified:
    llvm/trunk/include/llvm/Support/raw_ostream.h
    llvm/trunk/lib/Support/raw_ostream.cpp

Modified: llvm/trunk/include/llvm/Support/raw_ostream.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/raw_ostream.h?rev=77255&r1=77254&r2=77255&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/raw_ostream.h (original)
+++ llvm/trunk/include/llvm/Support/raw_ostream.h Mon Jul 27 16:46:02 2009
@@ -420,6 +420,7 @@
 
 public:
   explicit raw_null_ostream() {}
+  ~raw_null_ostream();
 };
 
 } // end llvm namespace

Modified: llvm/trunk/lib/Support/raw_ostream.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/raw_ostream.cpp?rev=77255&r1=77254&r2=77255&view=diff

==============================================================================
--- llvm/trunk/lib/Support/raw_ostream.cpp (original)
+++ llvm/trunk/lib/Support/raw_ostream.cpp Mon Jul 27 16:46:02 2009
@@ -438,6 +438,15 @@
 //  raw_null_ostream
 //===----------------------------------------------------------------------===//
 
+raw_null_ostream::~raw_null_ostream() {
+#ifndef NDEBUG
+  // ~raw_ostream asserts that the buffer is empty. This isn't necessary
+  // with raw_null_ostream, but it's better to have raw_null_ostream follow
+  // the rules than to change the rules just for raw_null_ostream.
+  flush();
+#endif
+}
+
 void raw_null_ostream::write_impl(const char *Ptr, size_t Size) {
 }
 





More information about the llvm-commits mailing list