This fixes the failure in test/Driver/autocomplete.c uncovered by D39245.
Details
Details
Diff Detail
Diff Detail
Event Timeline
Comment Actions
This is the order of options observed when the candidates are randomly shuffled:
Run 1: cl CL cl1.1 CL1.1 cl1.2 CL1.2 cl2.0 CL2.0
Run 2: CL cl cl1.1 CL1.1 cl1.2 CL1.2 CL2.0 cl2.0
Comment Actions
Maybe we should do case-insensitive string comparison first, and if two strings are considered the same, try again in case-sensitive manner? Otherwise, even though the output is now deterministic, the output order is still dependent on the order of input strings.
Comment Actions
Thanks! I agree it's a better idea to use a stronger sort predicate. I have updated the patch accordingly.
Comment Actions
Perhaps, this is a bit more straightforward.
if (int X = A.compare_lower(B)) return X < 0; return A.compare(B) < 0;
Comment Actions
LGTM
lib/Driver/Driver.cpp | ||
---|---|---|
1207 | I believe that if you use clang-format, }); will be put to a separate line like this. std::sort(SuggestedCompletions.begin(), SuggestedCompletions.end(), [](StringRef A, StringRef B) { if (int X = A.compare_lower(B)) return X < 0; return A.compare(B) > 0; }); |
I believe that if you use clang-format, }); will be put to a separate line like this.