mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-17 04:24:00 +00:00
Add DEBUG_WITH_TYPE as a clean alternative to tweaking DEBUG_TYPE.
This: -- #undef DEBUG_TYPE #define DEBUG_TYPE "foo" DEBUG(...) #undef DEBUG_TYPE #define DEBUG_TYPE "" -- becomes this: -- DEBUG_WITH_TYPE("foo", ...) -- git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78435 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -42,24 +42,36 @@ extern bool DebugFlag;
|
||||
//
|
||||
bool isCurrentDebugType(const char *Type);
|
||||
|
||||
// DEBUG_WITH_TYPE macro - This macro should be used by passes to emit debug
|
||||
// information. In the '-debug' option is specified on the commandline, and if
|
||||
// this is a debug build, then the code specified as the option to the macro
|
||||
// will be executed. Otherwise it will not be. Example:
|
||||
//
|
||||
// DEBUG_WITH_TYPE("bitset", errs() << "Bitset contains: " << Bitset << "\n");
|
||||
//
|
||||
// This will emit the debug information if -debug is present, and -debug-only is
|
||||
// not specified, or is specified as "bitset".
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define DEBUG_WITH_TYPE(TYPE, X) do { } while (0)
|
||||
#else
|
||||
#define DEBUG_WITH_TYPE(TYPE, X) \
|
||||
do { if (DebugFlag && isCurrentDebugType(TYPE)) { X; } } while (0)
|
||||
#endif
|
||||
|
||||
// DEBUG macro - This macro should be used by passes to emit debug information.
|
||||
// In the '-debug' option is specified on the commandline, and if this is a
|
||||
// debug build, then the code specified as the option to the macro will be
|
||||
// executed. Otherwise it will not be. Example:
|
||||
//
|
||||
// DEBUG(cerr << "Bitset contains: " << Bitset << "\n");
|
||||
// DEBUG(errs() << "Bitset contains: " << Bitset << "\n");
|
||||
//
|
||||
|
||||
#ifndef DEBUG_TYPE
|
||||
#define DEBUG_TYPE ""
|
||||
#endif
|
||||
|
||||
#ifdef NDEBUG
|
||||
#define DEBUG(X)
|
||||
#else
|
||||
#define DEBUG(X) \
|
||||
do { if (DebugFlag && isCurrentDebugType(DEBUG_TYPE)) { X; } } while (0)
|
||||
#endif
|
||||
#define DEBUG(X) DEBUG_WITH_TYPE(DEBUG_TYPE, X)
|
||||
|
||||
/// getNullOutputStream - Return a null string that does not output
|
||||
/// anything. This hides the static variable from other modules.
|
||||
|
Reference in New Issue
Block a user