Skip to content

Commit

Permalink
Fix opt --help ordering of available optimizations.
Browse files Browse the repository at this point in the history
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.

Differential Revision: https://reviews.llvm.org/D34831

llvm-svn: 306857
  • Loading branch information
Erich Keane committed Jun 30, 2017
1 parent 990f01f commit 60cb75f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions llvm/include/llvm/IR/LegacyPassNameParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ class PassNameParser : public PassRegistrationListener,
// 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,
const PassNameParser::OptionInfo *VT2) {
return VT1->Name < VT2->Name;
// ValCompare - Provide a sorting comparator for Values elements...
static int ValCompare(const PassNameParser::OptionInfo *VT1,
const PassNameParser::OptionInfo *VT2) {
return VT1->Name.compare(VT2->Name);
}
};

Expand Down

0 comments on commit 60cb75f

Please sign in to comment.