[clang-tools-extra] [clangd][modules] Remove the options when driver detects that it was unsupported, and log them (PR #200001)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 5 06:28:01 PDT 2026
https://github.com/Decodetalkers updated https://github.com/llvm/llvm-project/pull/200001
>From 4b856ad0fd28ffe18c0d13308f94ba720717cf15 Mon Sep 17 00:00:00 2001
From: ShootingStarDragons <ShootingStarDragons at protonmail.com>
Date: Fri, 5 Jun 2026 21:48:39 +0900
Subject: [PATCH] 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..d22adef96513f 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> UnsupportedArgs;
+
+ for (auto *UnknownArg : ArgList.filtered(options::OPT_UNKNOWN)) {
+ unsigned Index = UnknownArg->getIndex();
+ const auto *Argument = UnknownArg->getValue();
+ UnsupportedArgs.push_back(Argument);
+ IndicesToDrop.push_back(Index);
+ }
+
+ if (!UnsupportedArgs.empty()) {
+ std::string UnsupportedArguments = llvm::join(UnsupportedArgs, ", ");
+ log("Warning: detected unsupported Flags {0}", UnsupportedArguments);
+ }
+
llvm::sort(IndicesToDrop);
for (unsigned Idx : llvm::reverse(IndicesToDrop))
// +1 to account for the executable name in Cmd[0] that
More information about the cfe-commits
mailing list