#include <cerrno>
#include <cstdlib>
#include <map>
-#include <set>
using namespace llvm;
using namespace cl;
// Initialise the general option category.
OptionCategory llvm::cl::GeneralCategory("General options");
+struct HasName {
+ HasName(StringRef Name) : Name(Name) {}
+ bool operator()(const OptionCategory *Category) const {
+ return Name == Category->getName();
+ }
+ StringRef Name;
+};
+
void OptionCategory::registerCategory()
{
+ assert(std::count_if(RegisteredOptionCategories->begin(),
+ RegisteredOptionCategories->end(),
+ HasName(getName())) == 0 &&
+ "Duplicate option categories");
+
RegisteredOptionCategories->insert(this);
}
virtual void printOptions(StrOptionPairVector &Opts, size_t MaxArgLen) {
std::vector<OptionCategory *> SortedCategories;
std::map<OptionCategory *, std::vector<Option *> > CategorizedOptions;
- std::set<std::string> CategoryNames;
// Collect registered option categories into vector in preparation for
// sorting.
E = RegisteredOptionCategories->end();
I != E; ++I) {
SortedCategories.push_back(*I);
- // FIXME: Move this check to OptionCategory::registerCategory after the
- // problem with analyzer plugins linking to llvm/Support and causing
- // assertion on the duplicate llvm::cl::GeneralCategory is solved.
- assert(CategoryNames.insert((*I)->getName()).second &&
- "Duplicate option categories");
}
// Sort the different option categories alphabetically.