diff --git a/bolt/lib/Utils/CommandLineOpts.cpp b/bolt/lib/Utils/CommandLineOpts.cpp --- a/bolt/lib/Utils/CommandLineOpts.cpp +++ b/bolt/lib/Utils/CommandLineOpts.cpp @@ -135,12 +135,9 @@ cl::Optional, cl::cat(BoltOutputCategory)); -cl::opt -PerfData("perfdata", - cl::desc(""), - cl::Optional, - cl::cat(AggregatorCategory), - cl::sub(*cl::AllSubCommands)); +cl::opt PerfData("perfdata", cl::desc(""), cl::Optional, + cl::cat(AggregatorCategory), + cl::sub(cl::SubCommand::getAll())); static cl::alias PerfDataA("p", @@ -181,12 +178,9 @@ cl::cat(BoltCategory)); cl::opt -Verbosity("v", - cl::desc("set verbosity level for diagnostic output"), - cl::init(0), - cl::ZeroOrMore, - cl::cat(BoltCategory), - cl::sub(*cl::AllSubCommands)); + Verbosity("v", cl::desc("set verbosity level for diagnostic output"), + cl::init(0), cl::ZeroOrMore, cl::cat(BoltCategory), + cl::sub(cl::SubCommand::getAll())); bool processAllFunctions() { if (opts::AggregateOnly) diff --git a/bolt/tools/driver/llvm-bolt.cpp b/bolt/tools/driver/llvm-bolt.cpp --- a/bolt/tools/driver/llvm-bolt.cpp +++ b/bolt/tools/driver/llvm-bolt.cpp @@ -49,7 +49,7 @@ static cl::opt InputFilename(cl::Positional, cl::desc(""), cl::Required, cl::cat(BoltCategory), - cl::sub(*cl::AllSubCommands)); + cl::sub(cl::SubCommand::getAll())); static cl::opt InputDataFilename("data", diff --git a/clang/lib/Tooling/CommonOptionsParser.cpp b/clang/lib/Tooling/CommonOptionsParser.cpp --- a/clang/lib/Tooling/CommonOptionsParser.cpp +++ b/clang/lib/Tooling/CommonOptionsParser.cpp @@ -86,21 +86,21 @@ static cl::opt BuildPath("p", cl::desc("Build path"), cl::Optional, cl::cat(Category), - cl::sub(*cl::AllSubCommands)); + cl::sub(cl::SubCommand::getAll())); static cl::list SourcePaths( cl::Positional, cl::desc(" [... ]"), OccurrencesFlag, - cl::cat(Category), cl::sub(*cl::AllSubCommands)); + cl::cat(Category), cl::sub(cl::SubCommand::getAll())); static cl::list ArgsAfter( "extra-arg", cl::desc("Additional argument to append to the compiler command line"), - cl::cat(Category), cl::sub(*cl::AllSubCommands)); + cl::cat(Category), cl::sub(cl::SubCommand::getAll())); static cl::list ArgsBefore( "extra-arg-before", cl::desc("Additional argument to prepend to the compiler command line"), - cl::cat(Category), cl::sub(*cl::AllSubCommands)); + cl::cat(Category), cl::sub(cl::SubCommand::getAll())); cl::ResetAllOptionOccurrences(); diff --git a/clang/tools/clang-refactor/ClangRefactor.cpp b/clang/tools/clang-refactor/ClangRefactor.cpp --- a/clang/tools/clang-refactor/ClangRefactor.cpp +++ b/clang/tools/clang-refactor/ClangRefactor.cpp @@ -39,11 +39,11 @@ static cl::opt Verbose("v", cl::desc("Use verbose output"), cl::cat(cl::getGeneralCategory()), - cl::sub(*cl::AllSubCommands)); + cl::sub(cl::SubCommand::getAll())); static cl::opt Inplace("i", cl::desc("Inplace edit s"), cl::cat(cl::getGeneralCategory()), - cl::sub(*cl::AllSubCommands)); + cl::sub(cl::SubCommand::getAll())); } // end namespace opts diff --git a/llvm/include/llvm/Support/CommandLine.h b/llvm/include/llvm/Support/CommandLine.h --- a/llvm/include/llvm/Support/CommandLine.h +++ b/llvm/include/llvm/Support/CommandLine.h @@ -217,6 +217,13 @@ } SubCommand() = default; + // Get the special subcommand representing no subcommand. + static SubCommand &getTopLevel(); + + // Get the special subcommand that can be used to put an option into all + // subcomands. + static SubCommand &getAll(); + void reset(); explicit operator bool() const; @@ -309,7 +316,7 @@ } bool isInAllSubCommands() const { - return llvm::is_contained(Subs, &*AllSubCommands); + return llvm::is_contained(Subs, &SubCommand::getAll()); } //-------------------------------------------------------------------------=== @@ -1952,7 +1959,8 @@ /// Hopefully this API can be deprecated soon. Any situation where options need /// to be modified by tools or libraries should be handled by sane APIs rather /// than just handing around a global list. -StringMap