summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e4db795)
raw | patch | inline | side by side (parent: e4db795)
author | Alexander Kornienko <alexfh@google.com> | |
Thu, 27 Feb 2014 14:47:37 +0000 (14:47 +0000) | ||
committer | Alexander Kornienko <alexfh@google.com> | |
Thu, 27 Feb 2014 14:47:37 +0000 (14:47 +0000) |
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202404 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Support/CommandLine.h | patch | blob | history | |
lib/Support/CommandLine.cpp | patch | blob | history |
index 4e0b4512465887dd7471c5f2a1751f4f89f8b282..8d84f3f6dfea169ffed001f4a6a598c92ac7a3ca 100644 (file)
public:
OptionCategory(const char *const Name, const char *const Description = 0)
: Name(Name), Description(Description) { registerCategory(); }
- const char *getName() { return Name; }
- const char *getDescription() { return Description; }
+ const char *getName() const { return Name; }
+ const char *getDescription() const { return Description; }
};
// The general Option Category (used as default category).
index 7b2a4d0270f8415fd80fa4332df71bdf7c9d8b18..e1317a25986d918c8761824b1cf856cc6475543b 100644 (file)
#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.