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

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


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

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.

>From 255c261df90bd15d3bcee7a212758c2de4c56e69 Mon Sep 17 00:00:00 2001
From: Philip Reames <preames at rivosinc.com>
Date: Thu, 7 Dec 2023 13:51:26 -0800
Subject: [PATCH] [driver] Respect the mode the driver is in for autocomplete

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.
---
 clang/lib/Driver/Driver.cpp | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index e241706b9082ee..49e272f69d8130 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



More information about the cfe-commits mailing list