aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2013-09-10 23:22:56 +0000
committerEli Friedman <eli.friedman@gmail.com>2013-09-10 23:22:56 +0000
commitadd560eee426339135fbabcad764b2afad46285e (patch)
tree26162279901f83df25cfda6ae89753f955530164 /lib
parentae43dac30037395cce2b54af0a02500985813183 (diff)
downloadexternal_llvm-add560eee426339135fbabcad764b2afad46285e.zip
external_llvm-add560eee426339135fbabcad764b2afad46285e.tar.gz
external_llvm-add560eee426339135fbabcad764b2afad46285e.tar.bz2
Fix another mistake in r190442.
Sorry about that; I'll try to be more careful about DEBUG mode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190449 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Option/OptTable.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/Option/OptTable.cpp b/lib/Option/OptTable.cpp
index 5b4b5d3..78c5ea2 100644
--- a/lib/Option/OptTable.cpp
+++ b/lib/Option/OptTable.cpp
@@ -46,6 +46,35 @@ static int StrCmpOptionNameIgnoreCase(const char *A, const char *B) {
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;