https://github.com/Decodetalkers updated 
https://github.com/llvm/llvm-project/pull/200001

>From 22e2950f611e1aa91f61759f7b9c3601cf57f60b Mon Sep 17 00:00:00 2001
From: ShootingStarDragons <[email protected]>
Date: Fri, 5 Jun 2026 21:48:39 +0900
Subject: [PATCH 1/2] feat: remove unsupported compile options when driver
 detects them

and log the unsupported options to the editor
---
 clang-tools-extra/clangd/CompileCommands.cpp | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/clang-tools-extra/clangd/CompileCommands.cpp 
b/clang-tools-extra/clangd/CompileCommands.cpp
index 4eda330716f21..c589b622b66fa 100644
--- a/clang-tools-extra/clangd/CompileCommands.cpp
+++ b/clang-tools-extra/clangd/CompileCommands.cpp
@@ -273,6 +273,21 @@ void CommandMangler::operator()(tooling::CompileCommand 
&Command,
       SawInput(Cmd[I]);
     Cmd.resize(DashDashIndex);
   }
+
+  llvm::SmallVector<const char *, 16> UnknownArgs;
+
+  for (auto *UnknownArg : ArgList.filtered(options::OPT_UNKNOWN)) {
+    unsigned Index = UnknownArg->getIndex();
+    const auto *Argument = UnknownArg->getValue();
+    UnknownArgs.push_back(Argument);
+    IndicesToDrop.push_back(Index);
+  }
+
+  if (!UnknownArgs.empty()) {
+    log("Warning: detected unsupported Flags {0}",
+        llvm::join(UnknownArgs, ", "));
+  }
+
   llvm::sort(IndicesToDrop);
   for (unsigned Idx : llvm::reverse(IndicesToDrop))
     // +1 to account for the executable name in Cmd[0] that

>From e5ce41644f29553ce77d8c4aab444a611b8459f4 Mon Sep 17 00:00:00 2001
From: ShootingStarDragons <[email protected]>
Date: Fri, 5 Jun 2026 23:47:13 +0900
Subject: [PATCH 2/2] chore: add unit test for unknown flags drop

---
 .../clangd/unittests/CompileCommandsTests.cpp         | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp 
b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
index 0c1e0348f68a5..55b3434ebf860 100644
--- a/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
@@ -561,7 +561,18 @@ TEST(CommandMangler, ClangClStdFlags_Inference) {
     EXPECT_THAT(llvm::join(Cmd.CommandLine, " "), HasSubstr("/std:c++latest"));
   }
 }
+TEST(CommandMangler, ClangUnknownArgs) {
+  // Check that clang-cl-specific will drop unknown flags
+  const auto Mangler = CommandMangler::forTests();
 
+  {
+    tooling::CompileCommand Cmd;
+    Cmd.CommandLine = {"clang-cl", "-std=c++23", "--unknown-flag=abcd.flag"};
+    Mangler(Cmd, "/Users/foo.hpp");
+    EXPECT_THAT(llvm::join(Cmd.CommandLine, " "),
+                Not(HasSubstr("--unknown-flag=abcd.flag")));
+  }
+}
 } // namespace
 } // namespace clangd
 } // namespace clang

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to