[llvm-commits] CVS: llvm/lib/Support/Debug.cpp

Bill Wendling isanbard at gmail.com
Thu Nov 16 16:49:30 PST 2006



Changes in directory llvm/lib/Support:

Debug.cpp updated: 1.7 -> 1.8
---
Log message:

Added "DOUT" macro. This is used as a replacement for the std::cerr
stream. It centralizes the use of std::cerr so that static c'tor/d'tors
aren't scattered around all over the place. The way to use it is like this:

       DOUT << "This is a status line: " << Var << "\n";

If "-debug" is specified, it will print. Otherwise, it'll not print. If
NDEBUG is defined, the DOUT does nothing.


---
Diffs of the changes:  (+12 -0)

 Debug.cpp |   12 ++++++++++++
 1 files changed, 12 insertions(+)


Index: llvm/lib/Support/Debug.cpp
diff -u llvm/lib/Support/Debug.cpp:1.7 llvm/lib/Support/Debug.cpp:1.8
--- llvm/lib/Support/Debug.cpp:1.7	Thu Apr 21 17:52:05 2005
+++ llvm/lib/Support/Debug.cpp	Thu Nov 16 18:49:12 2006
@@ -25,6 +25,7 @@
 
 #include "llvm/Support/Debug.h"
 #include "llvm/Support/CommandLine.h"
+#include <iostream>
 using namespace llvm;
 
 bool llvm::DebugFlag;  // DebugFlag - Exported boolean set by the -debug option
@@ -63,3 +64,14 @@
   return false;
 #endif
 }
+
+// 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.
+// 
+llvm_ostream llvm::getErrorOutputStream(const char *DebugType) {
+  if (DebugFlag && isCurrentDebugType(DebugType))
+    return llvm_ostream(std::cerr);
+  else
+    return llvm_ostream();
+}






More information about the llvm-commits mailing list