Author: Nikita Popov Date: 2024-06-21T15:45:17+02:00 New Revision: 30299b87171cbad2dacb8b1ec0e75801785f16d9
URL: https://github.com/llvm/llvm-project/commit/30299b87171cbad2dacb8b1ec0e75801785f16d9 DIFF: https://github.com/llvm/llvm-project/commit/30299b87171cbad2dacb8b1ec0e75801785f16d9.diff LOG: [CommandLine] Avoid ManagedStatic.h include (NFC) The two variables using ManagedStatic that are exported by this header are not actually used anywhere -- they are used through SubCommand::getTopLevel() and SubCommand::getAll() instead. Drop the extern declarations and the include. Added: Modified: clang/lib/Frontend/PrecompiledPreamble.cpp lldb/utils/TableGen/LLDBTableGen.cpp llvm/include/llvm/Support/CommandLine.h llvm/lib/Support/CommandLine.cpp llvm/lib/Support/RandomNumberGenerator.cpp llvm/lib/Support/TypeSize.cpp Removed: ################################################################################ diff --git a/clang/lib/Frontend/PrecompiledPreamble.cpp b/clang/lib/Frontend/PrecompiledPreamble.cpp index fdf05c3613c95..cab5838fceb24 100644 --- a/clang/lib/Frontend/PrecompiledPreamble.cpp +++ b/clang/lib/Frontend/PrecompiledPreamble.cpp @@ -28,6 +28,7 @@ #include "llvm/Config/llvm-config.h" #include "llvm/Support/CrashRecoveryContext.h" #include "llvm/Support/FileSystem.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" #include "llvm/Support/VirtualFileSystem.h" diff --git a/lldb/utils/TableGen/LLDBTableGen.cpp b/lldb/utils/TableGen/LLDBTableGen.cpp index c63ca76c0d48f..bbd3f3d6c66c4 100644 --- a/lldb/utils/TableGen/LLDBTableGen.cpp +++ b/lldb/utils/TableGen/LLDBTableGen.cpp @@ -12,6 +12,7 @@ #include "LLDBTableGenBackends.h" // Declares all backends. #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/PrettyStackTrace.h" #include "llvm/Support/Signals.h" #include "llvm/TableGen/Error.h" diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h index b035209406b68..5d60bb64bbb20 100644 --- a/llvm/include/llvm/Support/CommandLine.h +++ b/llvm/include/llvm/Support/CommandLine.h @@ -28,7 +28,6 @@ #include "llvm/ADT/Twine.h" #include "llvm/ADT/iterator_range.h" #include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/StringSaver.h" #include "llvm/Support/raw_ostream.h" #include <cassert> @@ -237,12 +236,6 @@ class SubCommand { Option *ConsumeAfterOpt = nullptr; // The ConsumeAfter option if it exists. }; -// A special subcommand representing no subcommand -extern ManagedStatic<SubCommand> TopLevelSubCommand; - -// A special subcommand that can be used to put an option into all subcommands. -extern ManagedStatic<SubCommand> AllSubCommands; - class SubCommandGroup { SmallVector<SubCommand *, 4> Subs; diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 8a00d4798f33d..6dc0c86cea894 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -455,10 +455,10 @@ void OptionCategory::registerCategory() { // initialization because it is referenced from cl::opt constructors, which run // dynamically in an arbitrary order. LLVM_REQUIRE_CONSTANT_INITIALIZATION -ManagedStatic<SubCommand> llvm::cl::TopLevelSubCommand; +static ManagedStatic<SubCommand> TopLevelSubCommand; // A special subcommand that can be used to put an option into all subcommands. -ManagedStatic<SubCommand> llvm::cl::AllSubCommands; +static ManagedStatic<SubCommand> AllSubCommands; SubCommand &SubCommand::getTopLevel() { return *TopLevelSubCommand; } diff --git a/llvm/lib/Support/RandomNumberGenerator.cpp b/llvm/lib/Support/RandomNumberGenerator.cpp index 12fe109dbc2b5..2959fc2bfed17 100644 --- a/llvm/lib/Support/RandomNumberGenerator.cpp +++ b/llvm/lib/Support/RandomNumberGenerator.cpp @@ -19,6 +19,7 @@ #include "llvm/Support/CommandLine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/Error.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/raw_ostream.h" #ifdef _WIN32 #include "llvm/Support/Windows/WindowsSupport.h" diff --git a/llvm/lib/Support/TypeSize.cpp b/llvm/lib/Support/TypeSize.cpp index 8bed9b29cba55..43346b81cd676 100644 --- a/llvm/lib/Support/TypeSize.cpp +++ b/llvm/lib/Support/TypeSize.cpp @@ -8,6 +8,7 @@ #include "llvm/Support/TypeSize.h" #include "llvm/Support/CommandLine.h" +#include "llvm/Support/ManagedStatic.h" #include "llvm/Support/WithColor.h" #include "DebugOptions.h" _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits