Make raw_null_ostream flush its buffer in its destructor, so that
authorDan Gohman <gohman@apple.com>
Mon, 27 Jul 2009 21:46:02 +0000 (21:46 +0000)
committerDan Gohman <gohman@apple.com>
Mon, 27 Jul 2009 21:46:02 +0000 (21:46 +0000)
it conforms to the assertion added in r77245. This fixes a failure
in qa_override.c in clang's testsuite.

llvm-svn: 77255

llvm/include/llvm/Support/raw_ostream.h
llvm/lib/Support/raw_ostream.cpp

index 3527984..246fdb9 100644 (file)
@@ -420,6 +420,7 @@ class raw_null_ostream : public raw_ostream {
 
 public:
   explicit raw_null_ostream() {}
+  ~raw_null_ostream();
 };
 
 } // end llvm namespace
index 7e34e06..992c11a 100644 (file)
@@ -438,6 +438,15 @@ uint64_t raw_svector_ostream::tell() {
 //  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) {
 }