diff options
author | Alexander Kornienko <alexfh@google.com> | 2014-02-27 14:47:37 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2014-02-27 14:47:37 +0000 |
commit | 52a07b819e5bc1f681f56df4ac7c4ec8c27473c6 (patch) | |
tree | 21a316807b5d2aa43c339bb8cc174d5a6576dadb /llvm/lib/Support/CommandLine.cpp | |
parent | 46ebecc1fea39ce400444c8a24a209d4aaa89e27 (diff) | |
download | bcm5719-llvm-52a07b819e5bc1f681f56df4ac7c4ec8c27473c6.tar.gz bcm5719-llvm-52a07b819e5bc1f681f56df4ac7c4ec8c27473c6.zip |
Re-apply r200853, which should not crash after Clang plugins were converted to loadable modules in r201256.
llvm-svn: 202404
Diffstat (limited to 'llvm/lib/Support/CommandLine.cpp')
-rw-r--r-- | llvm/lib/Support/CommandLine.cpp | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/llvm/lib/Support/CommandLine.cpp b/llvm/lib/Support/CommandLine.cpp index 7b2a4d0270f..e1317a25986 100644 --- a/llvm/lib/Support/CommandLine.cpp +++ b/llvm/lib/Support/CommandLine.cpp @@ -36,7 +36,6 @@ #include <cerrno> #include <cstdlib> #include <map> -#include <set> using namespace llvm; using namespace cl; @@ -126,8 +125,21 @@ static ManagedStatic<OptionCatSet> RegisteredOptionCategories; // 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); } @@ -1506,7 +1518,6 @@ protected: 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. @@ -1514,11 +1525,6 @@ protected: 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. |