summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Support/Debug.cpp
diff options
context:
space:
mode:
authorBill Wendling <isanbard@gmail.com>2006-11-17 00:49:12 +0000
committerBill Wendling <isanbard@gmail.com>2006-11-17 00:49:12 +0000
commitd7fda04420720e7487820bd7dff663484dbea0db (patch)
tree26bf1c06be5f033ee17cf72db279680b208398e3 /llvm/lib/Support/Debug.cpp
parenta715288b4028308aaf4c1160f101928f2abd65da (diff)
downloadbcm5719-llvm-d7fda04420720e7487820bd7dff663484dbea0db.tar.gz
bcm5719-llvm-d7fda04420720e7487820bd7dff663484dbea0db.zip
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. llvm-svn: 31798
Diffstat (limited to 'llvm/lib/Support/Debug.cpp')
-rw-r--r--llvm/lib/Support/Debug.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/Support/Debug.cpp b/llvm/lib/Support/Debug.cpp
index 394d9c11094..cbf12c7c0d7 100644
--- a/llvm/lib/Support/Debug.cpp
+++ b/llvm/lib/Support/Debug.cpp
@@ -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 @@ bool llvm::isCurrentDebugType(const char *DebugType) {
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();
+}
OpenPOWER on IntegriCloud