[llvm] r190449 - Fix another mistake in r190442.

Eli Friedman eli.friedman at gmail.com
Tue Sep 10 16:22:56 PDT 2013


Author: efriedma
Date: Tue Sep 10 18:22:56 2013
New Revision: 190449

URL: http://llvm.org/viewvc/llvm-project?rev=190449&view=rev
Log:
Fix another mistake in r190442.

Sorry about that; I'll try to be more careful about DEBUG mode.

Modified:
    llvm/trunk/lib/Option/OptTable.cpp

Modified: llvm/trunk/lib/Option/OptTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Option/OptTable.cpp?rev=190449&r1=190448&r2=190449&view=diff
==============================================================================
--- llvm/trunk/lib/Option/OptTable.cpp (original)
+++ llvm/trunk/lib/Option/OptTable.cpp Tue Sep 10 18:22:56 2013
@@ -46,6 +46,35 @@ static int StrCmpOptionNameIgnoreCase(co
   return (a < b) ? -1 : 1;
 }
 
+#ifndef NDEBUG
+static int StrCmpOptionName(const char *A, const char *B) {
+  if (int N = StrCmpOptionNameIgnoreCase(A, B))
+    return N;
+  return strcmp(A, B);
+}
+
+static inline bool operator<(const OptTable::Info &A, const OptTable::Info &B) {
+  if (&A == &B)
+    return false;
+
+  if (int N = StrCmpOptionName(A.Name, B.Name))
+    return N < 0;
+
+  for (const char * const *APre = A.Prefixes,
+                  * const *BPre = B.Prefixes;
+                          *APre != 0 && *BPre != 0; ++APre, ++BPre) {
+    if (int N = StrCmpOptionName(*APre, *BPre))
+      return N < 0;
+  }
+
+  // Names are the same, check that classes are in order; exactly one
+  // should be joined, and it should succeed the other.
+  assert(((A.Kind == Option::JoinedClass) ^ (B.Kind == Option::JoinedClass)) &&
+         "Unexpected classes for options with same name.");
+  return B.Kind == Option::JoinedClass;
+}
+#endif
+
 // Support lower_bound between info and an option name.
 static inline bool operator<(const OptTable::Info &I, const char *Name) {
   return StrCmpOptionNameIgnoreCase(I.Name, Name) < 0;





More information about the llvm-commits mailing list