[PATCH] D26418: Add '-suppress-checks-filter' option to suppress diagnostics from certain files
Nikita Kakuev via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 8 13:15:13 PST 2016
nkakuev created this revision.
nkakuev added reviewers: malcolm.parsons, alexfh.
nkakuev added a subscriber: cfe-commits.
Currently clang-tidy doesn't provide a practical way to suppress diagnostics from headers you don't have control over. If using a function defined in such header causes a false positive, there is no easy way to deal with this issue.
Since you //cannot// modify a header, you //cannot// add NOLINT (or any other source annotations) to it. And adding NOLINT to each invocation of such function is either impossible or hugely impractical if invocations are ubiquitous.
Using the '-header-filter' doesn't help to address this issue as well. Unless your own headers are strategically named, it is virtually impossible to craft a regex that will filter out only the third-party ones.
The '-line-filter' can be used to suppress such warnings, but it's not very convenient. Instead of excluding a line that produces a warning you have to include all other lines. Plus, it provides no way to suppress only certain warnings from a file.
The option I propose solves aforementioned problems. It allows a user to specify a set of regular expressions to suppress diagnostics from files whose names match these expressions. Additionally, a set of checks can be specified to suppress only certain diagnostics.
The option can be used in the following way:
`clang-tidy -suppress-checks-filter='[{"name":"falty_header.h"},{"name":"third-party/","checks":"google-explicit-constructor"}]' source.cpp -- -c`
https://reviews.llvm.org/D26418
Files:
clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tidy/ClangTidyOptions.cpp
clang-tidy/ClangTidyOptions.h
clang-tidy/tool/ClangTidyMain.cpp
test/clang-tidy/Inputs/suppress-checks-filter/1/header1.h
test/clang-tidy/Inputs/suppress-checks-filter/1/header2.h
test/clang-tidy/Inputs/suppress-checks-filter/2/header3.h
test/clang-tidy/Inputs/suppress-checks-filter/2/header4.h
test/clang-tidy/suppress-checks-filter.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D26418.77242.patch
Type: text/x-patch
Size: 14938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20161108/5981d3ca/attachment-0001.bin>
More information about the cfe-commits
mailing list