[cfe-dev] [clang-tidy] Excluding individual files/lines from clang-tidy checks

Nikita via cfe-dev cfe-dev at lists.llvm.org
Fri Oct 28 12:55:00 PDT 2016


Hi,

I want to implement a mechanism to exclude individual files/lines from
clang-tidy checks. The existing '-line-filter' option isn't
particularly suitable for this purpose since it requires listing all
checked files along with line ranges. Furthermore, this functionality
was already requested (or at least mentioned) in this bug -
https://llvm.org/bugs/show_bug.cgi?id=25215 I believe it might be
useful to a broader audience as well.

I need advice on the interface of this mechanism. Other clan-tidy
options (like '-checks' or '-warnings-as-errors') use the minus sign
to denote an exclusion. However, this approach doesn't play well with
the JSON format of the '-line-filter' string. So I'm thinking about
adding another option - '-exclude-from-checks' - that will take a JSON
array identical to the one '-line-filter' takes:
> clang-tidy '-exclude-from-checks=[{"name":"exclude.c","lines":[[5,7]]}]' ...

I can process this option after the line filter. This way
'-exclude-from-checks' could be used together with both
'-header-filter' and '-line-filter'. Doing this will also maintain
backward-compatibility.

I would appreciate any suggestions or comments on my idea.

Regards,
Nikita



More information about the cfe-dev mailing list