llvm.org GIT mirror llvm / a36b81d
eliminate DOUT and make Debug.h not include Streams.h anymore, woo! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@79835 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 11 years ago
2 changed file(s) with 21 addition(s) and 58 deletion(s). Raw diff Collapse all Expand all
2525 #ifndef LLVM_SUPPORT_DEBUG_H
2626 #define LLVM_SUPPORT_DEBUG_H
2727
28 #include "llvm/Support/Streams.h"
29
3028 namespace llvm {
3129
3230 // DebugFlag - This boolean is set to true if the '-debug' command line option
3937 // specified on the command line, or if none was specified on the command line
4038 // with the -debug-only=X option.
4139 //
40 #ifndef NDEBUG
4241 bool isCurrentDebugType(const char *Type);
42 #else
43 #define isCurrentDebugType(X) (false)
44 #endif
4345
4446 // DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug
4547 // information. In the '-debug' option is specified on the commandline, and if
7173 #endif
7274
7375 #define DEBUG(X) DEBUG_WITH_TYPE(DEBUG_TYPE, X)
74
75 /// getNullOutputStream - Return a null string that does not output
76 /// anything. This hides the static variable from other modules.
77 ///
78 OStream &getNullOutputStream();
79
80 /// getErrorOutputStream - Returns the error output stream (std::cerr). This
81 /// places the std::c* I/O streams into one .cpp file and relieves the whole
82 /// program from having to have hundreds of static c'tor/d'tors for them.
83 ///
84 OStream &getErrorOutputStream(const char *DebugType);
85
86 #ifdef NDEBUG
87 #define DOUT llvm::getNullOutputStream()
88 #else
89 #define DOUT llvm::getErrorOutputStream(DEBUG_TYPE)
90 #endif
91
76
9277 } // End llvm namespace
9378
9479 #endif
2828
2929 bool llvm::DebugFlag; // DebugFlag - Exported boolean set by the -debug option
3030
31 namespace {
3231 #ifndef NDEBUG
33 // -debug - Command line option to enable the DEBUG statements in the passes.
34 // This flag may only be enabled in debug builds.
35 static cl::opt
36 Debug("debug", cl::desc("Enable debug output"), cl::Hidden,
37 cl::location(DebugFlag));
32 // -debug - Command line option to enable the DEBUG statements in the passes.
33 // This flag may only be enabled in debug builds.
34 static cl::opt
35 Debug("debug", cl::desc("Enable debug output"), cl::Hidden,
36 cl::location(DebugFlag));
3837
39 static std::string CurrentDebugType;
40 static struct DebugOnlyOpt {
41 void operator=(const std::string &Val) const {
42 DebugFlag |= !Val.empty();
43 CurrentDebugType = Val;
44 }
45 } DebugOnlyOptLoc;
38 static std::string CurrentDebugType;
39 static struct DebugOnlyOpt {
40 void operator=(const std::string &Val) const {
41 DebugFlag |= !Val.empty();
42 CurrentDebugType = Val;
43 }
44 } DebugOnlyOptLoc;
4645
47 static cl::opt >
48 DebugOnly("debug-only", cl::desc("Enable a specific type of debug output"),
49 cl::Hidden, cl::value_desc("debug string"),
50 cl::location(DebugOnlyOptLoc), cl::ValueRequired);
46 static cl::opt >
47 DebugOnly("debug-only", cl::desc("Enable a specific type of debug output"),
48 cl::Hidden, cl::value_desc("debug string"),
49 cl::location(DebugOnlyOptLoc), cl::ValueRequired);
5150 #endif
52 }
5351
5452 // isCurrentDebugType - Return true if the specified string is the debug type
5553 // specified on the command line, or if none was specified on the command line
6260 return false;
6361 #endif
6462 }
65
66 /// getNullOutputStream - Return a null string that does not output
67 /// anything. This hides the static variable from other modules.
68 ///
69 OStream &llvm::getNullOutputStream() {
70 static llvm::OStream NullStream(0);
71 return NullStream;
72 }
73
74 // getErrorOutputStream - Returns the error output stream (std::cerr). This
75 // places the std::c* I/O streams into one .cpp file and relieves the whole
76 // program from having to have hundreds of static c'tor/d'tors for them.
77 //
78 OStream &llvm::getErrorOutputStream(const char *DebugType) {
79 static OStream cnoout(0);
80 if (DebugFlag && isCurrentDebugType(DebugType))
81 return cerr;
82 else
83 return cnoout;
84 }