[llvm-commits] [llvm] r104806 - /llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp

Daniel Dunbar daniel at zuster.org
Wed May 26 22:31:33 PDT 2010


Author: ddunbar
Date: Thu May 27 00:31:32 2010
New Revision: 104806

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

Modified:
    llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp

Modified: llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp?rev=104806&r1=104805&r2=104806&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/AsmMatcherEmitter.cpp Thu May 27 00:31:32 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-commits mailing list