// Initialise the general option category.
OptionCategory llvm::cl::GeneralCategory("General options");
-void OptionCategory::registerCategory()
-{
+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);
}
free(Dup);
}
}
- const char *SaveString(const char *Str) LLVM_OVERRIDE {
+ const char *SaveString(const char *Str) override {
char *Dup = strdup(Str);
Dups.push_back(Dup);
return Dup;
MoreHelp->clear();
// Halt the program since help information was printed
- exit(1);
+ exit(0);
}
};
// It shall return true if A's name should be lexographically
// ordered before B's name. It returns false otherwise.
static bool OptionCategoryCompare(OptionCategory *A, OptionCategory *B) {
- int Length = strcmp(A->getName(), B->getName());
- assert(Length != 0 && "Duplicate option categories");
- return Length < 0;
+ return strcmp(A->getName(), B->getName()) < 0;
}
// Make sure we inherit our base class's operator=()
// sorting.
for (OptionCatSet::const_iterator I = RegisteredOptionCategories->begin(),
E = RegisteredOptionCategories->end();
- I != E; ++I)
+ I != E; ++I) {
SortedCategories.push_back(*I);
+ }
// Sort the different option categories alphabetically.
assert(SortedCategories.size() > 0 && "No option categories registered!");
if (OverrideVersionPrinter != 0) {
(*OverrideVersionPrinter)();
- exit(1);
+ exit(0);
}
print();
(*I)();
}
- exit(1);
+ exit(0);
}
};
} // End anonymous namespace