diff options
author | Mehdi Amini <joker.eph@gmail.com> | 2021-07-16 03:46:22 +0000 |
---|---|---|
committer | Mehdi Amini <joker.eph@gmail.com> | 2021-07-16 03:46:53 +0000 |
commit | 16b5e9d6a269913e8da0fa037e8af32eaf304c8f (patch) | |
tree | 2029314f1156239954ae10c5eb6748a303fdfc14 /llvm/lib/Support/Debug.cpp | |
parent | 42f588f39c5ce6f521e3709b8871d1fdd076292f (diff) | |
download | llvm-16b5e9d6a269913e8da0fa037e8af32eaf304c8f.zip llvm-16b5e9d6a269913e8da0fa037e8af32eaf304c8f.tar.gz llvm-16b5e9d6a269913e8da0fa037e8af32eaf304c8f.tar.bz2 |
Revert "Use ManagedStatic and lazy initialization of cl::opt in libSupport to make it free of global initializer"
This reverts commit 42f588f39c5ce6f521e3709b8871d1fdd076292f.
Broke some buildbots
Diffstat (limited to 'llvm/lib/Support/Debug.cpp')
-rw-r--r-- | llvm/lib/Support/Debug.cpp | 73 |
1 files changed, 21 insertions, 52 deletions
diff --git a/llvm/lib/Support/Debug.cpp b/llvm/lib/Support/Debug.cpp index b48045c..19b40ab 100644 --- a/llvm/lib/Support/Debug.cpp +++ b/llvm/lib/Support/Debug.cpp @@ -30,8 +30,6 @@ #include "llvm/Support/circular_raw_ostream.h" #include "llvm/Support/raw_ostream.h" -#include "DebugOptions.h" - #undef isCurrentDebugType #undef setCurrentDebugType #undef setCurrentDebugTypes @@ -81,32 +79,21 @@ void setCurrentDebugTypes(const char **Types, unsigned Count) { // All Debug.h functionality is a no-op in NDEBUG mode. #ifndef NDEBUG -namespace { -struct CreateDebug { - static void *call() { - return new cl::opt<bool, true>("debug", cl::desc("Enable debug output"), - cl::Hidden, cl::location(DebugFlag)); - } -}; +// -debug - Command line option to enable the DEBUG statements in the passes. +// This flag may only be enabled in debug builds. +static cl::opt<bool, true> +Debug("debug", cl::desc("Enable debug output"), cl::Hidden, + cl::location(DebugFlag)); // -debug-buffer-size - Buffer the last N characters of debug output //until program termination. -struct CreateDebugBufferSize { - static void *call() { - return new cl::opt<unsigned>( - "debug-buffer-size", - cl::desc("Buffer the last N characters of debug output " - "until program termination. " - "[default 0 -- immediate print-out]"), - cl::Hidden, cl::init(0)); - } -}; -} // namespace - -// -debug - Command line option to enable the DEBUG statements in the passes. -// This flag may only be enabled in debug builds. -static ManagedStatic<cl::opt<bool, true>, CreateDebug> Debug; -static ManagedStatic<cl::opt<unsigned>, CreateDebugBufferSize> DebugBufferSize; +static cl::opt<unsigned> +DebugBufferSize("debug-buffer-size", + cl::desc("Buffer the last N characters of debug output " + "until program termination. " + "[default 0 -- immediate print-out]"), + cl::Hidden, + cl::init(0)); namespace { @@ -121,33 +108,15 @@ struct DebugOnlyOpt { CurrentDebugType->push_back(std::string(dbgType)); } }; -} // namespace -static DebugOnlyOpt DebugOnlyOptLoc; - -namespace { -struct CreateDebugOnly { - static void *call() { - return new cl::opt<DebugOnlyOpt, true, cl::parser<std::string>>( - "debug-only", - cl::desc("Enable a specific type of debug output (comma separated list " - "of types)"), - cl::Hidden, cl::ZeroOrMore, cl::value_desc("debug string"), - cl::location(DebugOnlyOptLoc), cl::ValueRequired); - } -}; } // namespace -static ManagedStatic<cl::opt<DebugOnlyOpt, true, cl::parser<std::string>>, - CreateDebugOnly> - DebugOnly; - -void llvm::initDebugOptions() { - *Debug; - *DebugBufferSize; - *DebugOnly; -} +static DebugOnlyOpt DebugOnlyOptLoc; +static cl::opt<DebugOnlyOpt, true, cl::parser<std::string> > +DebugOnly("debug-only", cl::desc("Enable a specific type of debug output (comma separated list of types)"), + cl::Hidden, cl::ZeroOrMore, cl::value_desc("debug string"), + cl::location(DebugOnlyOptLoc), cl::ValueRequired); // Signal handlers - dump debug output on termination. static void debug_user_sig_handler(void *Cookie) { // This is a bit sneaky. Since this is under #ifndef NDEBUG, we @@ -165,10 +134,10 @@ raw_ostream &llvm::dbgs() { static struct dbgstream { circular_raw_ostream strm; - dbgstream() - : strm(errs(), "*** Debug Log Output ***\n", - (!EnableDebugBuffering || !DebugFlag) ? 0 : *DebugBufferSize) { - if (EnableDebugBuffering && DebugFlag && *DebugBufferSize != 0) + dbgstream() : + strm(errs(), "*** Debug Log Output ***\n", + (!EnableDebugBuffering || !DebugFlag) ? 0 : DebugBufferSize) { + if (EnableDebugBuffering && DebugFlag && DebugBufferSize != 0) // TODO: Add a handler for SIGUSER1-type signals so the user can // force a debug dump. sys::AddSignalHandler(&debug_user_sig_handler, nullptr); |