[PATCH] D40234: [AutoComplete] Stable sort autocomplete candidates to remove non-deterministic ordering

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


mgrang created this revision.
mgrang added a project: clang.

This fixes the failure in test/Driver/autocomplete.c uncovered by https://reviews.llvm.org/D39245.


https://reviews.llvm.org/D40234

Files:
  lib/Driver/Driver.cpp


Index: lib/Driver/Driver.cpp
===================================================================
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -1199,7 +1199,7 @@
   // deterministic order. We could sort in any way, but we chose
   // 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(),
+  std::stable_sort(SuggestedCompletions.begin(), SuggestedCompletions.end(),
             [](StringRef A, StringRef B) { return A.compare_lower(B) < 0; });
 
   llvm::outs() << llvm::join(SuggestedCompletions, "\n") << '\n';


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


More information about the cfe-commits mailing list