This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Add a SuppressedChecks option to ignore diagnostics from specific checks
AbandonedPublic

Authored by reyg on Dec 22 2021, 5:45 AM.

Details

Reviewers
None

Diff Detail

Event Timeline

reyg created this revision.Dec 22 2021, 5:45 AM
reyg requested review of this revision.Dec 22 2021, 5:45 AM
Herald added a project: Restricted Project. · View Herald TranscriptDec 22 2021, 5:45 AM

Could you summarize what problem this is solving? There's multiple ways to "ignore diagnostics from specific checks", I think it would be confusing to add yet another one.

lebedev.ri added a subscriber: cfe-commits.
reyg added a comment.Dec 22 2021, 6:06 AM

I actually couldn't find a way to black-list specific checks. Is there a way to do that?

carlosgalvezp added a comment.EditedDec 22 2021, 6:21 AM

I actually couldn't find a way to black-list specific checks. Is there a way to do that?

Just prepend a dash to the check name that you want to disable:

checks=cppcoreguidelines-*,-cppcoreguidelines-pro-type-pointer-arithmetic

This will enable all checks from cppcoreguidelines except cppcoreguidelines-pro-type-pointer-arithmetic.

Normally you do this with pretty formatting in the .clang-tidy file:

Checks: > 
    cppcoreguidelines-*,
    -cppcoreguidelines-pro-type-pointer-arithmetic,
    -cppcoreguidelines-avoid-c-arrays,
reyg abandoned this revision.Dec 22 2021, 6:26 AM

Well now I feel stupid for not realizing that, thanks for pointing it out :)

At least I learned how to hack around in clang-tidy 😄

carlosgalvezp added a comment.EditedDec 22 2021, 6:48 AM

No worries, it's indeed good practice! Feel free to take a look at the docs, where this (and many more features) is described :)
https://clang.llvm.org/extra/clang-tidy/

will disable all default checks (-*) and enable all clang-analyzer-* checks except for clang-analyzer-cplusplus* ones.

And of course if you think something is unclear feel free to improve it :)