[PATCH] D34557: Sort the autocomplete candidates before printing them out.
Rui Ueyama via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 23 08:38:41 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306116: Sort the autocomplete candidates before printing them out. (authored by ruiu).
Changed prior to commit:
https://reviews.llvm.org/D34557?vs=103731&id=103733#toc
Repository:
rL LLVM
https://reviews.llvm.org/D34557
Files:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/autocomplete.c
Index: cfe/trunk/lib/Driver/Driver.cpp
===================================================================
--- cfe/trunk/lib/Driver/Driver.cpp
+++ cfe/trunk/lib/Driver/Driver.cpp
@@ -1245,6 +1245,13 @@
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;
}
Index: cfe/trunk/test/Driver/autocomplete.c
===================================================================
--- cfe/trunk/test/Driver/autocomplete.c
+++ cfe/trunk/test/Driver/autocomplete.c
@@ -11,26 +11,26 @@
// RUN: %clang --autocomplete=-meabi,d | FileCheck %s -check-prefix=MEABI
// MEABI: default
// RUN: %clang --autocomplete=-meabi, | FileCheck %s -check-prefix=MEABIALL
-// MEABIALL: default 4 5 gnu
+// MEABIALL: 4 5 default gnu
// RUN: %clang --autocomplete=-cl-std=,CL2 | FileCheck %s -check-prefix=CLSTD
// CLSTD: CL2.0
// RUN: %clang --autocomplete=-cl-std=, | FileCheck %s -check-prefix=CLSTDALL
// CLSTDALL: cl CL cl1.1 CL1.1 cl1.2 CL1.2 cl2.0 CL2.0
// RUN: %clang --autocomplete=-fno-sanitize-coverage=,f | FileCheck %s -check-prefix=FNOSANICOVER
// FNOSANICOVER: func
// RUN: %clang --autocomplete=-fno-sanitize-coverage=, | FileCheck %s -check-prefix=FNOSANICOVERALL
-// FNOSANICOVERALL: func bb edge indirect-calls trace-bb trace-cmp trace-div trace-gep 8bit-counters trace-pc trace-pc-guard no-prune inline-8bit-counters
+// FNOSANICOVERALL: 8bit-counters bb edge func indirect-calls inline-8bit-counters no-prune trace-bb trace-cmp trace-div trace-gep trace-pc trace-pc-guard
// RUN: %clang --autocomplete=-ffp-contract=, | FileCheck %s -check-prefix=FFPALL
-// FFPALL: fast on off
+// FFPALL: fast off on
// RUN: %clang --autocomplete=-flto=, | FileCheck %s -check-prefix=FLTOALL
-// FLTOALL: thin full
+// FLTOALL: full thin
// RUN: %clang --autocomplete=-fveclib=, | FileCheck %s -check-prefix=FVECLIBALL
-// FVECLIBALL: Accelerate SVML none
+// FVECLIBALL: Accelerate none SVML
// RUN: %clang --autocomplete=-fshow-overloads=, | FileCheck %s -check-prefix=FSOVERALL
-// FSOVERALL: best all
+// FSOVERALL: all best
// RUN: %clang --autocomplete=-fvisibility=, | FileCheck %s -check-prefix=FVISIBILITYALL
-// FVISIBILITYALL: hidden default
+// FVISIBILITYALL: default hidden
// RUN: %clang --autocomplete=-mfloat-abi=, | FileCheck %s -check-prefix=MFLOATABIALL
-// MFLOATABIALL: soft softfp hard
+// MFLOATABIALL: hard soft softfp
// RUN: %clang --autocomplete=-mthread-model, | FileCheck %s -check-prefix=MTHREADMODELALL
// MTHREADMODELALL: posix single
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34557.103733.patch
Type: text/x-patch
Size: 3025 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170623/d00798a7/attachment.bin>
More information about the cfe-commits
mailing list