[clang-tools-extra] [clang-tidy] New option to remove arguments from the command line (PR #164344)
Carlos Galvez via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 21 01:57:47 PDT 2025
=?utf-8?q?Félix-Antoine?= Constantin,
=?utf-8?q?Félix-Antoine?= Constantin,
=?utf-8?q?Félix-Antoine?= Constantin
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/164344 at github.com>
================
@@ -581,6 +581,24 @@ runClangTidy(clang::tidy::ClangTidyContext &Context,
return AdjustedArgs;
};
+ // Remove unwanted arguments passed to the compiler
+ ArgumentsAdjuster CompilationArgsToRemove =
+ [&Context](const CommandLineArguments &Args, StringRef Filename) {
+ ClangTidyOptions Opts = Context.getOptionsForFile(Filename);
+ CommandLineArguments AdjustedArgs = Args;
+
+ if (Opts.RemovedArgs) {
+ for (StringRef ArgToIgnore : *Opts.RemovedArgs) {
+ AdjustedArgs.erase(std::remove(AdjustedArgs.begin(),
+ AdjustedArgs.end(), ArgToIgnore),
+ AdjustedArgs.end());
+ }
+ }
+
+ return AdjustedArgs;
+ };
+
+ Tool.appendArgumentsAdjuster(CompilationArgsToRemove);
----------------
carlosgalvezp wrote:
Nit: for consistency with the one for `ExtraArgs`, maybe we can call this `PerFileArgumentRemover`?
https://github.com/llvm/llvm-project/pull/164344
More information about the cfe-commits
mailing list