[clang] [Clang][Driver] New parameter allow-unrecognized-arguments (PR #162201)

Carlos Galvez via cfe-commits cfe-commits at lists.llvm.org
Sat Oct 11 11:25:58 PDT 2025


carlosgalvezp wrote:

> We're not removing those flags, we are simply downgrading the error to a warning. 

The flags would be ignored/removed and not passed to clang-tidy (because it can't understand them). This means clang-tidy would analyze code based on different semantics compared to what GCC is seeing. Depending on which checks are enabled, this may lead to false positives/negatives, which the user would then report to us. 

> But the aforementioned flags would not prevent clang from compiling the code if they were ignored, they are simply used as optimization in the final binary

This is not true in the general case, it depends on the flag. 

I would be inclined to have something like the original PR, i.e. add a `RemovedArgs` flag or similar to clang-tidy, which is the opposite of `ExtraArgs`, where the user lists the flags that shall be removed. No regex, no "ignore all unknown flags", no "downgrade errors to warnings", no magic. Plain and simply the user must spell out each and every flag they want to remove. This is then explicit and auditable at any point in time.

Additionally, document that if people use these features, they do so at their own risk and may lead to further errors or false positives/negatives. Once again, a pre-requisite for a correct clang-tidy analysis is that clang can compile the code without errors.

https://github.com/llvm/llvm-project/pull/162201


More information about the cfe-commits mailing list