]> granicus.if.org Git - llvm/commitdiff
Correct OptionCategoryCompare() in the command line library.
authorDaniel Sanders <daniel_l_sanders@apple.com>
Mon, 27 Mar 2017 13:43:24 +0000 (13:43 +0000)
committerDaniel Sanders <daniel_l_sanders@apple.com>
Mon, 27 Mar 2017 13:43:24 +0000 (13:43 +0000)
Summary:
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.

Reviewers: qcolombet

Reviewed By: qcolombet

Subscribers: qcolombet, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298844 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Support/CommandLine.cpp

index 65747d6929155a4e7be26133510e2e0c70c5a82f..f4a9108b8544e5ea776b242a59ac4b2906acf696 100644 (file)
@@ -1852,10 +1852,11 @@ public:
 
   // 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=()