[llvm] r303670 - [GSoC] Shell autocompletion for clang
Yuka Takahashi via llvm-commits
llvm-commits at lists.llvm.org
Tue May 23 11:39:09 PDT 2017
Author: yamaguchi
Date: Tue May 23 13:39:08 2017
New Revision: 303670
URL: http://llvm.org/viewvc/llvm-project?rev=303670&view=rev
Log:
[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
Modified:
llvm/trunk/include/llvm/Option/OptTable.h
llvm/trunk/lib/Option/OptTable.cpp
Modified: llvm/trunk/include/llvm/Option/OptTable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Option/OptTable.h?rev=303670&r1=303669&r2=303670&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Option/OptTable.h (original)
+++ llvm/trunk/include/llvm/Option/OptTable.h Tue May 23 13:39:08 2017
@@ -113,6 +113,14 @@ public:
return getInfo(id).MetaVar;
}
+ /// Find flags from OptTable which starts with Cur.
+ ///
+ /// \param [in] Cur - String prefix that all returned flags need
+ // to start with.
+ ///
+ /// \return The vector of flags which start with Cur.
+ std::vector<std::string> findByPrefix(StringRef Cur) const;
+
/// \brief Parse a single argument; returning the new argument and
/// updating Index.
///
Modified: llvm/trunk/lib/Option/OptTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Option/OptTable.cpp?rev=303670&r1=303669&r2=303670&view=diff
==============================================================================
--- llvm/trunk/lib/Option/OptTable.cpp (original)
+++ llvm/trunk/lib/Option/OptTable.cpp Tue May 23 13:39:08 2017
@@ -186,6 +186,20 @@ static unsigned matchOption(const OptTab
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 {
More information about the llvm-commits
mailing list