[llvm-commits] [llvm] r89368 - /llvm/trunk/utils/TableGen/OptParserEmitter.cpp

Daniel Dunbar daniel at zuster.org
Thu Nov 19 10:22:16 PST 2009


Author: ddunbar
Date: Thu Nov 19 12:22:16 2009
New Revision: 89368

URL: http://llvm.org/viewvc/llvm-project?rev=89368&view=rev
Log:
TableGen/OptParser: When ordering options, make "sentinel" options appear before
everything else.

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

Modified: llvm/trunk/utils/TableGen/OptParserEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/OptParserEmitter.cpp?rev=89368&r1=89367&r2=89368&view=diff

==============================================================================
--- llvm/trunk/utils/TableGen/OptParserEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/OptParserEmitter.cpp Thu Nov 19 12:22:16 2009
@@ -35,9 +35,16 @@
   const Record *A = *(Record**) Av;
   const Record *B = *(Record**) Bv;
 
-  // Compare options by name first.
-  if (int Cmp = StrCmpOptionName(A->getValueAsString("Name").c_str(),
-                                 B->getValueAsString("Name").c_str()))
+  // Sentinel options preceed all others and are only ordered by precedence.
+  bool ASent = A->getValueAsDef("Kind")->getValueAsBit("Sentinel");
+  bool BSent = B->getValueAsDef("Kind")->getValueAsBit("Sentinel");
+  if (ASent != BSent)
+    return ASent ? -1 : 1;
+
+  // Compare options by name, unless they are sentinels.
+  if (!ASent)
+    if (int Cmp = StrCmpOptionName(A->getValueAsString("Name").c_str(),
+                                   B->getValueAsString("Name").c_str()))
     return Cmp;
 
   // Then by the kind precedence;





More information about the llvm-commits mailing list