Reputation: 396
I'm running clang-tidy on a header file header.h. However as some of the warning outputs, it's outputting system headers:
.../include/c++/8/bits/std_abs.h:46:8: error: expected identifier or '(' [clang-diagnostic-error]
extern "C++"
../include/c++/8/cctype:62:1: error: unknown type name 'namespace' [clang-diagnostic-error]
namespace std
../include/c++/8/cctype:62:14: error: expected ';' after top level declarator [clang-diagnostic-error]
namespace std
..
etc
The problem: I don't want to see the warnings for anything other than the source file I'm scanning, for either a source file or header file.
I've tried implementing the fix here (What is the correct way of providing header-filter for clang-tidy in Cmake?) using --header-filter
but it didnt work. I added the path to the header file that I was scanning in the regex, but I was still seeing the system header warnings.
Upvotes: 1
Views: 1360
Reputation: 2663
For clang-tidy
to work your code needs to be compile-able by the clang
backend to generate an AST. This is apparently not the case since clang-diagnostic-error
is basically a compilation error.
The problem is you are including headers that cannot be compiled by clang, there is no way to filter that out.
Upvotes: 1