Skip to content

Commit 30299b8

Browse files
committed
[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.
1 parent 4232dd5 commit 30299b8

File tree

6 files changed

+6
-9
lines changed

6 files changed

+6
-9
lines changed

clang/lib/Frontend/PrecompiledPreamble.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "llvm/Config/llvm-config.h"
2929
#include "llvm/Support/CrashRecoveryContext.h"
3030
#include "llvm/Support/FileSystem.h"
31+
#include "llvm/Support/ManagedStatic.h"
3132
#include "llvm/Support/Path.h"
3233
#include "llvm/Support/Process.h"
3334
#include "llvm/Support/VirtualFileSystem.h"

lldb/utils/TableGen/LLDBTableGen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "LLDBTableGenBackends.h" // Declares all backends.
1414
#include "llvm/Support/CommandLine.h"
15+
#include "llvm/Support/ManagedStatic.h"
1516
#include "llvm/Support/PrettyStackTrace.h"
1617
#include "llvm/Support/Signals.h"
1718
#include "llvm/TableGen/Error.h"

llvm/include/llvm/Support/CommandLine.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include "llvm/ADT/Twine.h"
2929
#include "llvm/ADT/iterator_range.h"
3030
#include "llvm/Support/ErrorHandling.h"
31-
#include "llvm/Support/ManagedStatic.h"
3231
#include "llvm/Support/StringSaver.h"
3332
#include "llvm/Support/raw_ostream.h"
3433
#include <cassert>
@@ -237,12 +236,6 @@ class SubCommand {
237236
Option *ConsumeAfterOpt = nullptr; // The ConsumeAfter option if it exists.
238237
};
239238

240-
// A special subcommand representing no subcommand
241-
extern ManagedStatic<SubCommand> TopLevelSubCommand;
242-
243-
// A special subcommand that can be used to put an option into all subcommands.
244-
extern ManagedStatic<SubCommand> AllSubCommands;
245-
246239
class SubCommandGroup {
247240
SmallVector<SubCommand *, 4> Subs;
248241

llvm/lib/Support/CommandLine.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -455,10 +455,10 @@ void OptionCategory::registerCategory() {
455455
// initialization because it is referenced from cl::opt constructors, which run
456456
// dynamically in an arbitrary order.
457457
LLVM_REQUIRE_CONSTANT_INITIALIZATION
458-
ManagedStatic<SubCommand> llvm::cl::TopLevelSubCommand;
458+
static ManagedStatic<SubCommand> TopLevelSubCommand;
459459

460460
// A special subcommand that can be used to put an option into all subcommands.
461-
ManagedStatic<SubCommand> llvm::cl::AllSubCommands;
461+
static ManagedStatic<SubCommand> AllSubCommands;
462462

463463
SubCommand &SubCommand::getTopLevel() { return *TopLevelSubCommand; }
464464

llvm/lib/Support/RandomNumberGenerator.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include "llvm/Support/CommandLine.h"
2020
#include "llvm/Support/Debug.h"
2121
#include "llvm/Support/Error.h"
22+
#include "llvm/Support/ManagedStatic.h"
2223
#include "llvm/Support/raw_ostream.h"
2324
#ifdef _WIN32
2425
#include "llvm/Support/Windows/WindowsSupport.h"

llvm/lib/Support/TypeSize.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "llvm/Support/TypeSize.h"
1010
#include "llvm/Support/CommandLine.h"
11+
#include "llvm/Support/ManagedStatic.h"
1112
#include "llvm/Support/WithColor.h"
1213

1314
#include "DebugOptions.h"

0 commit comments

Comments
 (0)