[PATCH] D30996: Correct OptionCategoryCompare() in the command line library.

Daniel Sanders via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 15 12:19:51 PDT 2017


dsanders created this revision.

It should return <0, 0, or >0 for less-than, equal, and greater-than like
strcmp() (according to the history, it used to be implemented with
strcmp()) but it actually returned 0, or 1 for not-equal and equal.


https://reviews.llvm.org/D30996

Files:
  lib/Support/CommandLine.cpp


Index: lib/Support/CommandLine.cpp
===================================================================
--- lib/Support/CommandLine.cpp
+++ lib/Support/CommandLine.cpp
@@ -1852,10 +1852,11 @@
 
   // Helper function for printOptions().
   // It shall return a negative value if A's name should be lexicographically
-  // ordered before B's name. It returns a value greater equal zero otherwise.
+  // ordered before B's name. It returns a value greater than zero if B's name
+  // should be ordered before A's name, and it returns 0 otherwise.
   static int OptionCategoryCompare(OptionCategory *const *A,
                                    OptionCategory *const *B) {
-    return (*A)->getName() == (*B)->getName();
+    return (*A)->getName().compare((*B)->getName());
   }
 
   // Make sure we inherit our base class's operator=()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D30996.91913.patch
Type: text/x-patch
Size: 834 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170315/394e3dbd/attachment.bin>


More information about the llvm-commits mailing list