[clang-tools-extra] Add option to exclude headers from clang-tidy analysis (PR #91400)

Justin Cady via cfe-commits cfe-commits at lists.llvm.org
Wed May 8 08:42:14 PDT 2024


justincady wrote:

> I wonder what is the target scenario for this feature.

This PR addresses clang-tidy's lack of ability to ignore some set of headers when analyzing a file (most commonly third party code that cannot be modified).

>  I remember regex can excluding some pattern, the we can exclude header file in `HeaderFilterRegex`.

The underlying regex implementation for `HeaderFilterRegex` is `llvm::Regex` which does not support negative lookahead. See:

- https://reviews.llvm.org/D34654
- https://lists.llvm.org/pipermail/cfe-dev/2015-November/046203.html
- https://github.com/llvm/llvm-project/issues/25590

As I mentioned in the description, one option to allow exclusion of headers would be migrating to `std::regex`. But I think that has the potential to break existing configs, which is why reviving/reimplementing D34654 seems like the best path forward to me.

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


More information about the cfe-commits mailing list