[llvm] r200858 - Revert "Fix an invalid check for duplicate option categories."

Rafael Espindola rafael.espindola at gmail.com
Wed Feb 5 09:49:31 PST 2014


Author: rafael
Date: Wed Feb  5 11:49:31 2014
New Revision: 200858

URL: http://llvm.org/viewvc/llvm-project?rev=200858&view=rev
Log:
Revert "Fix an invalid check for duplicate option categories."

This reverts commit r200853.

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

Modified:
    llvm/trunk/include/llvm/Support/CommandLine.h
    llvm/trunk/lib/Support/CommandLine.cpp

Modified: llvm/trunk/include/llvm/Support/CommandLine.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/CommandLine.h?rev=200858&r1=200857&r2=200858&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/CommandLine.h (original)
+++ llvm/trunk/include/llvm/Support/CommandLine.h Wed Feb  5 11:49:31 2014
@@ -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).

Modified: llvm/trunk/lib/Support/CommandLine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/CommandLine.cpp?rev=200858&r1=200857&r2=200858&view=diff
==============================================================================
--- llvm/trunk/lib/Support/CommandLine.cpp (original)
+++ llvm/trunk/lib/Support/CommandLine.cpp Wed Feb  5 11:49:31 2014
@@ -125,21 +125,8 @@ static ManagedStatic<OptionCatSet> Regis
 // 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=()





More information about the llvm-commits mailing list