[llvm-branch-commits] [llvm-branch] r104846 - /llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp

Daniel Dunbar daniel at zuster.org
Thu May 27 09:34:15 PDT 2010


Author: ddunbar
Date: Thu May 27 11:34:15 2010
New Revision: 104846

URL: http://llvm.org/viewvc/llvm-project?rev=104846&view=rev
Log:
AsmMatcher: Ensure classes are totally ordered, so we can std::sort them reliably.

Modified:
    llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp

Modified: llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp?rev=104846&r1=104845&r2=104846&view=diff
==============================================================================
--- llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/branches/Apple/whitney/utils/TableGen/AsmMatcherEmitter.cpp Thu May 27 11:34:15 2010
@@ -388,6 +388,9 @@
 
   /// operator< - Compare two classes.
   bool operator<(const ClassInfo &RHS) const {
+    if (this == &RHS)
+      return false;
+
     // Unrelated classes can be ordered by kind.
     if (!isRelatedTo(RHS))
       return Kind < RHS.Kind;
@@ -403,7 +406,13 @@
 
     default:
       // This class preceeds the RHS if it is a proper subset of the RHS.
-      return this != &RHS && isSubsetOf(RHS);
+      if (isSubsetOf(RHS))
+	return true;
+      if (RHS.isSubsetOf(*this))
+	return false;
+
+      // Otherwise, order by name to ensure we have a total ordering.
+      return ValueName < RHS.ValueName;
     }
   }
 };





More information about the llvm-branch-commits mailing list