Revert "Fix an invalid check for duplicate option categories."
authorRafael Espindola <rafael.espindola@gmail.com>
Wed, 5 Feb 2014 17:49:31 +0000 (17:49 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Wed, 5 Feb 2014 17:49:31 +0000 (17:49 +0000)
This reverts commit r200853.

It was causing clang/Analysis/checker-plugins.c to crash.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200858 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Support/CommandLine.h
lib/Support/CommandLine.cpp

index b29fc8736034993d025625d5cb9f00ae73019eb6..515b0bd00f93f657fad8a8d14188a0ae286913bd 100644 (file)
@@ -149,8 +149,8 @@ private:
 public:
   OptionCategory(const char *const Name, const char *const Description = 0)
       : Name(Name), Description(Description) { registerCategory(); }
-  const char *getName() const { return Name; }
-  const char *getDescription() const { return Description; }
+  const char *getName() { return Name; }
+  const char *getDescription() { return Description; }
 };
 
 // The general Option Category (used as default category).
index 289bb87433f384e3c44faef518c179a6cbef20d5..16db4d639606515d052f1b5f7e942445c0d5d3a8 100644 (file)
@@ -125,21 +125,8 @@ 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);
 }
 
@@ -1508,7 +1495,9 @@ public:
   // 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) {
-    return strcmp(A->getName(), B->getName()) < 0;
+    int Length = strcmp(A->getName(), B->getName());
+    assert(Length != 0 && "Duplicate option categories");
+    return Length < 0;
   }
 
   // Make sure we inherit our base class's operator=()