[llvm] r326684 - [Bash-autocompletion] Pass all flags in shell command-line to Clang
Yuka Takahashi via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 5 00:54:21 PST 2018
Author: yamaguchi
Date: Mon Mar 5 00:54:20 2018
New Revision: 326684
URL: http://llvm.org/viewvc/llvm-project?rev=326684&view=rev
Log:
[Bash-autocompletion] Pass all flags in shell command-line to Clang
Previously, we passed "#" to --autocomplete to indicate to enable cc1
flags. For example, when -cc1 or -Xclang was passed to bash, bash
executed `clang --autocomplete=#-<flag they want to complete>`.
However, this was not a good implementation because it depends -Xclang
and -cc1 parsing to shell. So I changed this to pass all flags shell
has, so that Clang can handle them internally.
I had to change many testcases because API spec changed quite a lot.
Reviewers: teemperor, v.g.vassilev
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D39342
Modified:
llvm/trunk/lib/Option/OptTable.cpp
Modified: llvm/trunk/lib/Option/OptTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Option/OptTable.cpp?rev=326684&r1=326683&r2=326684&view=diff
==============================================================================
--- llvm/trunk/lib/Option/OptTable.cpp (original)
+++ llvm/trunk/lib/Option/OptTable.cpp Mon Mar 5 00:54:20 2018
@@ -219,7 +219,7 @@ OptTable::suggestValueCompletions(String
std::vector<std::string> Result;
for (StringRef Val : Candidates)
- if (Val.startswith(Arg))
+ if (Val.startswith(Arg) && Arg.compare(Val))
Result.push_back(Val);
return Result;
}
@@ -240,7 +240,7 @@ OptTable::findByPrefix(StringRef Cur, un
std::string S = std::string(In.Prefixes[I]) + std::string(In.Name) + "\t";
if (In.HelpText)
S += In.HelpText;
- if (StringRef(S).startswith(Cur))
+ if (StringRef(S).startswith(Cur) && S.compare(std::string(Cur) + "\t"))
Ret.push_back(S);
}
}
More information about the llvm-commits
mailing list