[PATCH] D40234: [AutoComplete] Use stronger sort predicate for autocomplete candidates to remove non-deterministic ordering

Mandeep Singh Grang via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Nov 19 22:21:59 PST 2017


mgrang updated this revision to Diff 123538.
mgrang retitled this revision from "[AutoComplete] Stable sort autocomplete candidates to remove non-deterministic ordering" to "[AutoComplete] Use stronger sort predicate for autocomplete candidates to remove non-deterministic ordering".
mgrang added a comment.

Added a stronger sorting predicate instead of stable sort.


https://reviews.llvm.org/D40234

Files:
  lib/Driver/Driver.cpp


Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1200,7 +1200,10 @@
   // case-insensitive sorting for consistency with the -help option
   // which prints out options in the case-insensitive alphabetical order.
   std::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(),
-            [](StringRef A, StringRef B) { return A.compare_lower(B) < 0; });
+            [](StringRef A, StringRef B) {
+              return A.equals_lower(B) ?
+                     A.compare(B) == 1 :
+                     A.compare_lower(B) < 0; });
 
   llvm::outs() << llvm::join(SuggestedCompletions, "\n") << '\n';
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D40234.123538.patch
Type: text/x-patch
Size: 716 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171120/44629de2/attachment.bin>


More information about the cfe-commits mailing list