diff options
| author | Rui Ueyama <ruiu@google.com> | 2017-06-23 15:37:52 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2017-06-23 15:37:52 +0000 |
| commit | 5cb4b35b80e9f6c5f7bc494dd67787910e760a8b (patch) | |
| tree | ff9f591acb8314379c6f0f8c8896e29cd6516aca /clang/lib/Driver | |
| parent | d064e91eceb97bdf1fc7b24af1b849f265828318 (diff) | |
| download | bcm5719-llvm-5cb4b35b80e9f6c5f7bc494dd67787910e760a8b.tar.gz bcm5719-llvm-5cb4b35b80e9f6c5f7bc494dd67787910e760a8b.zip | |
Sort the autocomplete candidates before printing them out.
Currently, autocompleted options are displayed in the same order as we
wrote them in .td files. This patch sort them out in clang so that they
are sorted alphabetically. This should improve usability.
Differential Revision: https://reviews.llvm.org/D34557
llvm-svn: 306116
Diffstat (limited to 'clang/lib/Driver')
| -rw-r--r-- | clang/lib/Driver/Driver.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 850f6bc9dde..c8f389bfb0f 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -1245,6 +1245,13 @@ bool Driver::HandleImmediateArgs(const Compilation &C) { SuggestedCompletions = Opts->suggestValueCompletions(Option, Arg); } + // Sort the autocomplete candidates so that shells print them out in a + // 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(), + [](StringRef A, StringRef B) { return A.compare_lower(B) < 0; }); + llvm::outs() << llvm::join(SuggestedCompletions, " ") << '\n'; return false; } |

