1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[Bash-autocompletion] Auto complete cc1 options if -cc1 is specified

Summary:
We don't want to autocomplete flags whose Flags class has `NoDriverOption` when argv[1] is not `-cc1`.

Another idea for this implementation is to make --autocomplete a cc1
option and handle it in clang Frontend, by porting --autocomplete
handler from Driver to Frontend, so that we can handle Driver options
and CC1 options in unified manner.

Differential Revision: https://reviews.llvm.org/D34770

llvm-svn: 307479
This commit is contained in:
Yuka Takahashi 2017-07-08 17:48:59 +00:00
parent 9e73a14fba
commit c2d79dd55e
2 changed files with 7 additions and 2 deletions

View File

@ -140,7 +140,8 @@ public:
// to start with.
///
/// \return The vector of flags which start with Cur.
std::vector<std::string> findByPrefix(StringRef Cur) const;
std::vector<std::string> findByPrefix(StringRef Cur,
unsigned short DisableFlags) const;
/// \brief Parse a single argument; returning the new argument and
/// updating Index.

View File

@ -225,11 +225,15 @@ OptTable::suggestValueCompletions(StringRef Option, StringRef Arg) const {
return {};
}
std::vector<std::string> OptTable::findByPrefix(StringRef Cur) const {
std::vector<std::string>
OptTable::findByPrefix(StringRef Cur, unsigned short DisableFlags) const {
std::vector<std::string> Ret;
for (const Info &In : OptionInfos.slice(FirstSearchableIndex)) {
if (!In.Prefixes || (!In.HelpText && !In.GroupID))
continue;
if (In.Flags & DisableFlags)
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))