diff options
author | Yuka Takahashi <yukatkh@gmail.com> | 2017-05-23 18:39:08 +0000 |
---|---|---|
committer | Yuka Takahashi <yukatkh@gmail.com> | 2017-05-23 18:39:08 +0000 |
commit | c8068dbb071725ec8be6c53420138964726cdc38 (patch) | |
tree | 192f34ad42a4c07b778b770b221dc6438df7cb9e /llvm/lib/Option/OptTable.cpp | |
parent | 7b0a6aa6426ed1abd844d109ad0b56f6743736b8 (diff) | |
download | bcm5719-llvm-c8068dbb071725ec8be6c53420138964726cdc38.tar.gz bcm5719-llvm-c8068dbb071725ec8be6c53420138964726cdc38.zip |
[GSoC] Shell autocompletion for clang
Summary:
This is a first patch for GSoC project, bash-completion for clang.
To use this on bash, please run `source clang/utils/bash-autocomplete.sh`.
bash-autocomplete.sh is code for bash-completion.
Simple flag completion and path completion is available in this patch.
Reviewers: teemperor, v.g.vassilev, ruiu, Bigcheese, efriedma
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D33237
llvm-svn: 303670
Diffstat (limited to 'llvm/lib/Option/OptTable.cpp')
-rw-r--r-- | llvm/lib/Option/OptTable.cpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp index 7eafb00855d..b00d21ec8f6 100644 --- a/llvm/lib/Option/OptTable.cpp +++ b/llvm/lib/Option/OptTable.cpp @@ -186,6 +186,20 @@ static unsigned matchOption(const OptTable::Info *I, StringRef Str, return 0; } +std::vector<std::string> OptTable::findByPrefix(StringRef Cur) const { + std::vector<std::string> Ret; + for (const Info &In : OptionInfos.slice(FirstSearchableIndex)) { + if (!In.Prefixes) + continue; + for (int I = 0; In.Prefixes[I]; I++) { + std::string S = std::string(In.Prefixes[I]) + std::string(In.Name); + if (StringRef(S).startswith(Cur)) + Ret.push_back(S); + } + } + return Ret; +} + Arg *OptTable::ParseOneArg(const ArgList &Args, unsigned &Index, unsigned FlagsToInclude, unsigned FlagsToExclude) const { |