[clang] [driver] Respect the mode the driver is in for autocomplete (PR #74770)

via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 7 13:57:35 PST 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-driver

Author: Philip Reames (preames)

<details>
<summary>Changes</summary>

The previous code was always auto-completing options for the clang mode.  We'd special cases flang to allow both clang and flang options, but this doesn't match either the help output or the actual argument parsing.  Seemingly, the obvious thing to do is to auto-complete with the same options we'd accept?

Note: Advice on how to test this is very welcome.  I don't see any testing in tree for anything except clang, and I don't personally use this auto complete feature at all.

---
Full diff: https://github.com/llvm/llvm-project/pull/74770.diff


1 Files Affected:

- (modified) clang/lib/Driver/Driver.cpp (+1-6) 


``````````diff
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e241706b9082e..49e272f69d813 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1991,12 +1991,7 @@ void Driver::HandleAutocompletions(StringRef PassedFlags) const {
   std::vector<std::string> SuggestedCompletions;
   std::vector<std::string> Flags;
 
-  llvm::opt::Visibility VisibilityMask(options::ClangOption);
-
-  // Make sure that Flang-only options don't pollute the Clang output
-  // TODO: Make sure that Clang-only options don't pollute Flang output
-  if (IsFlangMode())
-    VisibilityMask = llvm::opt::Visibility(options::FlangOption);
+  llvm::opt::Visibility VisibilityMask =  getOptionVisibilityMask();
 
   // Distinguish "--autocomplete=-someflag" and "--autocomplete=-someflag,"
   // because the latter indicates that the user put space before pushing tab

``````````

</details>


https://github.com/llvm/llvm-project/pull/74770


More information about the cfe-commits mailing list