[llvm] r229172 - NFC. Moving the RegisteredOptionCategories global into the CommandLineParser class.
Chris Bieneman
beanz at apple.com
Fri Feb 13 14:54:32 PST 2015
Author: cbieneman
Date: Fri Feb 13 16:54:32 2015
New Revision: 229172
URL: http://llvm.org/viewvc/llvm-project?rev=229172&view=rev
Log:
NFC. Moving the RegisteredOptionCategories global into the CommandLineParser class.
Modified:
llvm/trunk/lib/Support/CommandLine.cpp
Modified: llvm/trunk/lib/Support/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=229172&r1=229171&r2=229172&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp (original)
+++ llvm/trunk/lib/Support/CommandLine.cpp Fri Feb 13 16:54:32 2015
@@ -101,6 +101,9 @@ public:
Option *ConsumeAfterOpt; // The ConsumeAfter option if it exists.
+ // This collects the different option categories that have been registered.
+ SmallPtrSet<OptionCategory *, 16> RegisteredOptionCategories;
+
CommandLineParser() : ProgramOverview(nullptr), ConsumeAfterOpt(nullptr) {}
void ParseCommandLineOptions(int argc, const char *const *argv,
@@ -191,6 +194,17 @@ public:
void printOptionValues();
+ void registerCategory(OptionCategory *cat) {
+ assert(std::count_if(RegisteredOptionCategories.begin(),
+ RegisteredOptionCategories.end(),
+ [cat](const OptionCategory *Category) {
+ return getName() == Category->getName();
+ }) == 0 &&
+ "Duplicate option categories");
+
+ RegisteredOptionCategories.insert(cat);
+ }
+
private:
Option *LookupOption(StringRef &Arg, StringRef &Value);
};
@@ -220,22 +234,11 @@ void Option::setArgStr(const char *S) {
ArgStr = S;
}
-// This collects the different option categories that have been registered.
-typedef SmallPtrSet<OptionCategory *, 16> OptionCatSet;
-static ManagedStatic<OptionCatSet> RegisteredOptionCategories;
-
// Initialise the general option category.
OptionCategory llvm::cl::GeneralCategory("General options");
void OptionCategory::registerCategory() {
- assert(std::count_if(RegisteredOptionCategories->begin(),
- RegisteredOptionCategories->end(),
- [this](const OptionCategory *Category) {
- return getName() == Category->getName();
- }) == 0 &&
- "Duplicate option categories");
-
- RegisteredOptionCategories->insert(this);
+ GlobalParser->registerCategory(this);
}
//===----------------------------------------------------------------------===//
@@ -1577,8 +1580,8 @@ protected:
// Collect registered option categories into vector in preparation for
// sorting.
- for (OptionCatSet::const_iterator I = RegisteredOptionCategories->begin(),
- E = RegisteredOptionCategories->end();
+ for (auto I = GlobalParser->RegisteredOptionCategories.begin(),
+ E = GlobalParser->RegisteredOptionCategories.end();
I != E; ++I) {
SortedCategories.push_back(*I);
}
@@ -1721,7 +1724,7 @@ void HelpPrinterWrapper::operator=(bool
// Decide which printer to invoke. If more than one option category is
// registered then it is useful to show the categorized help instead of
// uncategorized help.
- if (RegisteredOptionCategories->size() > 1) {
+ if (GlobalParser->RegisteredOptionCategories.size() > 1) {
// unhide -help-list option so user can have uncategorized output if they
// want it.
HLOp.setHiddenFlag(NotHidden);
More information about the llvm-commits
mailing list