[llvm] r307479 - [Bash-autocompletion] Auto complete cc1 options if -cc1 is specified
Yuka Takahashi via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 8 10:48:59 PDT 2017
Author: yamaguchi
Date: Sat Jul 8 10:48:59 2017
New Revision: 307479
URL: http://llvm.org/viewvc/llvm-project?rev=307479&view=rev
Log:
[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
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=307479&r1=307478&r2=307479&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Option/OptTable.h (original)
+++ llvm/trunk/include/llvm/Option/OptTable.h Sat Jul 8 10:48:59 2017
@@ -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.
Modified: llvm/trunk/lib/Option/OptTable.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Option/OptTable.cpp?rev=307479&r1=307478&r2=307479&view=diff
==============================================================================
--- llvm/trunk/lib/Option/OptTable.cpp (original)
+++ llvm/trunk/lib/Option/OptTable.cpp Sat Jul 8 10:48:59 2017
@@ -225,11 +225,15 @@ OptTable::suggestValueCompletions(String
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))
More information about the llvm-commits
mailing list