Skip to content

Commit

Permalink
[AutoComplete] Use stronger sort predicate for autocomplete candidate…
Browse files Browse the repository at this point in the history
…s to remove non-deterministic ordering

Summary: This fixes the failure in test/Driver/autocomplete.c uncovered by D39245.

Reviewers: yamaguchi, teemperor, ruiu

Reviewed By: yamaguchi, ruiu

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 318681
  • Loading branch information
Mandeep Singh Grang committed Nov 20, 2017
1 parent dc9de50 commit 8f54ae1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion clang/lib/Driver/Driver.cpp
Expand Up @@ -1198,7 +1198,11 @@ void Driver::handleAutocompletions(StringRef PassedFlags) const {
// 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) {
if (int X = A.compare_lower(B))
return X < 0;
return A.compare(B) > 0;
});

llvm::outs() << llvm::join(SuggestedCompletions, "\n") << '\n';
}
Expand Down

0 comments on commit 8f54ae1

Please sign in to comment.