Hide the DOUT static variable behind a function interface.
authorDavid Greene <greened@obbligato.org>
Mon, 20 Jul 2009 16:16:06 +0000 (16:16 +0000)
committerDavid Greene <greened@obbligato.org>
Mon, 20 Jul 2009 16:16:06 +0000 (16:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@76425 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 0ebed202e4b2fdec6a7abf77d74eab0bf2db56cd..489a076dc395f191ccb646d16d4b48afe81e7668 100644 (file)
@@ -61,6 +61,11 @@ bool isCurrentDebugType(const char *Type);
   do { if (DebugFlag && isCurrentDebugType(DEBUG_TYPE)) { X; } } while (0)
 #endif
 
+/// getNullOutputStream - Return a null string that does not output
+/// anything.  This hides the static variable from other modules.
+///
+OStream &getNullOutputStream();
+
 /// getErrorOutputStream - Returns the error output stream (std::cerr). This
 /// places the std::c* I/O streams into one .cpp file and relieves the whole
 /// program from having to have hundreds of static c'tor/d'tors for them.
@@ -68,8 +73,7 @@ bool isCurrentDebugType(const char *Type);
 OStream &getErrorOutputStream(const char *DebugType);
 
 #ifdef NDEBUG
-static llvm::OStream NullStream(0);
-#define DOUT llvm::NullStream
+#define DOUT llvm::getNullOutputStream()
 #else
 #define DOUT llvm::getErrorOutputStream(DEBUG_TYPE)
 #endif
index a09cddf9022a5fc2086465ce8504c44b28749b92..b6beddb369d3fa1cfb22553c988e98aa5975875f 100644 (file)
@@ -64,6 +64,14 @@ bool llvm::isCurrentDebugType(const char *DebugType) {
 #endif
 }
 
+/// getNullOutputStream - Return a null string that does not output
+/// anything.  This hides the static variable from other modules.
+///
+OStream &llvm::getNullOutputStream() {
+  static llvm::OStream NullStream(0);
+  return NullStream;
+}
+
 // getErrorOutputStream - Returns the error output stream (std::cerr). This
 // places the std::c* I/O streams into one .cpp file and relieves the whole
 // program from having to have hundreds of static c'tor/d'tors for them.