From: Chris Bieneman Date: Wed, 3 Sep 2014 17:50:14 +0000 (+0000) Subject: Removing static initializer from Debug.cpp by converting to a ManagedStatic. X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=commitdiff_plain;h=b9053f6cbc40677fe6b91ed5243e3f8cdb0bb3c0 Removing static initializer from Debug.cpp by converting to a ManagedStatic. This is part of our larger effort to remove static initializers from LLVM libraries. Reviewed by: chandlerc git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@217053 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Support/Debug.cpp b/lib/Support/Debug.cpp index ad4d4ef1d92..824654257ac 100644 --- a/lib/Support/Debug.cpp +++ b/lib/Support/Debug.cpp @@ -27,6 +27,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Signals.h" #include "llvm/Support/circular_raw_ostream.h" +#include "llvm/Support/ManagedStatic.h" using namespace llvm; @@ -50,14 +51,14 @@ DebugBufferSize("debug-buffer-size", cl::Hidden, cl::init(0)); -static std::string CurrentDebugType; +static ManagedStatic CurrentDebugType; namespace { struct DebugOnlyOpt { void operator=(const std::string &Val) const { DebugFlag |= !Val.empty(); - CurrentDebugType = Val; + *CurrentDebugType = Val; } }; @@ -86,7 +87,7 @@ static void debug_user_sig_handler(void *Cookie) { // with the -debug-only=X option. // bool llvm::isCurrentDebugType(const char *DebugType) { - return CurrentDebugType.empty() || DebugType == CurrentDebugType; + return CurrentDebugType->empty() || DebugType == *CurrentDebugType; } /// setCurrentDebugType - Set the current debug type, as if the -debug-only=X @@ -94,7 +95,7 @@ bool llvm::isCurrentDebugType(const char *DebugType) { /// debug output to be produced. /// void llvm::setCurrentDebugType(const char *Type) { - CurrentDebugType = Type; + *CurrentDebugType = Type; } /// dbgs - Return a circular-buffered debug stream.