[PATCH] D34831: Fix opt --help ordering of available optimizations.

Erich Keane via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 29 12:41:45 PDT 2017


erichkeane created this revision.

Introduced in -r283004, the PassNameParser sorts Optimization options in reverse.  This is because the commit replaced a compare function with "<" (which would seemingly be proper based on the name of the comparison function).  The result is the 'true' result is converted to '1', which is inverted.

This patch fixes this by replacing the '<' operator call on StringRef with a call to the StringRef compare function.  It also renames the function to better reflect its meaning.


Repository:
  rL LLVM

https://reviews.llvm.org/D34831

Files:
  include/llvm/IR/LegacyPassNameParser.h


Index: include/llvm/IR/LegacyPassNameParser.h
===================================================================
--- include/llvm/IR/LegacyPassNameParser.h
+++ include/llvm/IR/LegacyPassNameParser.h
@@ -81,15 +81,15 @@
   // default implementation to sort the table before we print...
   void printOptionInfo(const cl::Option &O, size_t GlobalWidth) const override {
     PassNameParser *PNP = const_cast<PassNameParser*>(this);
-    array_pod_sort(PNP->Values.begin(), PNP->Values.end(), ValLessThan);
+    array_pod_sort(PNP->Values.begin(), PNP->Values.end(), ValCompare);
     cl::parser<const PassInfo*>::printOptionInfo(O, GlobalWidth);
   }
 
 private:
-  // ValLessThan - Provide a sorting comparator for Values elements...
-  static int ValLessThan(const PassNameParser::OptionInfo *VT1,
+  // ValCompare - Provide a sorting comparator for Values elements...
+  static int ValCompare(const PassNameParser::OptionInfo *VT1,
                          const PassNameParser::OptionInfo *VT2) {
-    return VT1->Name < VT2->Name;
+    return VT1->Name.compare(VT2->Name);
   }
 };
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34831.104723.patch
Type: text/x-patch
Size: 1088 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170629/f263027c/attachment.bin>


More information about the llvm-commits mailing list