[llvm-commits] [llvm] r76425 - in /llvm/trunk: include/llvm/Support/Debug.h lib/Support/Debug.cpp

David Greene greened at obbligato.org
Mon Jul 20 09:16:12 PDT 2009


Author: greened
Date: Mon Jul 20 11:16:06 2009
New Revision: 76425

URL: http://llvm.org/viewvc/llvm-project?rev=76425&view=rev
Log:

Hide the DOUT static variable behind a function interface.

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

Modified: llvm/trunk/include/llvm/Support/Debug.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/Debug.h?rev=76425&r1=76424&r2=76425&view=diff

==============================================================================
--- llvm/trunk/include/llvm/Support/Debug.h (original)
+++ llvm/trunk/include/llvm/Support/Debug.h Mon Jul 20 11:16:06 2009
@@ -61,6 +61,11 @@
   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 @@
 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

Modified: llvm/trunk/lib/Support/Debug.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Debug.cpp?rev=76425&r1=76424&r2=76425&view=diff

==============================================================================
--- llvm/trunk/lib/Support/Debug.cpp (original)
+++ llvm/trunk/lib/Support/Debug.cpp Mon Jul 20 11:16:06 2009
@@ -64,6 +64,14 @@
 #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.





More information about the llvm-commits mailing list