I have a problem with clang-tidy
. Basically, it analyzes each of my project files, but for the headers that are included in more than one .cpp
file, it prints redundant errors.
The problem is, Visual Studio Code has its PROBLEMS
tab, which picks every single one of them, so for a file definitions.hpp
which is included in 3 separate .cpp
files I end up with something like this:
The console output is:
[build] [3/4 25% :: 14.699] Building CXX object CMakeFiles\solver.dir\src\definitions.cpp.obj
[build] [...]\build\..\src/definitions.hpp:1:9: warning: header guard does not follow preferred style [llvm-header-guard]
[build] #ifndef DEFINITIONS_HPP
[build] ^~~~~~~~~~~~~~~
[...]
[build] [3/4 50% :: 16.138] Building CXX object CMakeFiles\solver.dir\src\genetic_algorithm.cpp.obj
[build] [...]\build\..\src/definitions.hpp:1:9: warning: header guard does not follow preferred style [llvm-header-guard]
[build] #ifndef DEFINITIONS_HPP
[build] ^~~~~~~~~~~~~~~
[...]
[build] [3/4 75% :: 17.362] Building CXX object CMakeFiles\solver.dir\src\main.cpp.obj
[build] [...]\build\..\src/definitions.hpp:1:9: warning: header guard does not follow preferred style [llvm-header-guard]
[build] #ifndef DEFINITIONS_HPP
[build] ^~~~~~~~~~~~~~~
So, is there a way to prevent something like this? I mean it doubles of triples my error list.
@Edit
So this is my clang-tidy
-relevant part of CMakeLists.txt
:
if(CMAKE_VERSION VERSION_GREATER 3.6)
option(CLANG_TIDY_FIX "Perform fixes for Clang-Tidy" OFF)
find_program(
CLANG_TIDY_EXE
NAMES "clang-tidy"
DOC "Path to clang-tidy executable"
)
if(CLANG_TIDY_EXE)
if(CLANG_TIDY_FIX)
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}" "-fix")
else()
message("SETTING UP CLANG TIDY")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE}")
endif()
endif()
endif()
And this is my .clang-tidy
file:
---
Checks: '*'
HeaderFilterRegex: '.*'
AnalyzeTemporaryDtors: false
FormatStyle: none
...