[clang-tools-extra] [clangd][modules] Remove the options when driver detects that it was unsupported, and log them (PR #200001)
Aleksandr Platonov via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 5 07:39:11 PDT 2026
================
@@ -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);
----------------
ArcsinX wrote:
- You can use `llvm::join(UnsupportedArgs, ", ")` return value directly.
- Put '{0}' into single quotes, this will make this message more readable, because we have spaces inside
- these options are `unknown`, but not `unsupported`
- maybe `option` word is more suitable here than `Flag`
- after you remove `std::string UnsupportedArguments = llvm::join(UnsupportedArgs, ", ");`, this `if` body became single-statement. For single-statement bodies we don't need `{}` (see https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements )
I.e. something like this
`log("Warning: detected unknown options: '{0}'",llvm::join(UnsupportedArgs, ", "));`
P.S. maybe we can skip unsupported options too? For the reference
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Options/Options.h#L24
https://github.com/llvm/llvm-project/pull/200001
More information about the cfe-commits
mailing list