我正在为我的项目使用 CMake,我想为项目引入 clang-tidy 检查。
我使用这个目的CMAKE_CXX_CLANG_TIDY
和.clang-tidy
文件检查设置。
我想使用警告作为错误在 CI 中有可靠的方法来检查提交是否引入了一些新的违规行为。不幸的是,由于 3rd 方库,我在启用检查时遇到了一些问题。例如,我使用Eigen
which 是仅标头库。由于这个事实,我在我的代码中收到了一些警告,例如。“a_file.cpp”
/snap/cmake/301/bin/cmake -E __run_co_compile --tidy="clang-tidy;--extra-arg-before=--driver-mode=g++" --source=../../a_file.cpp -- /usr/bin/clang++ -DEIGEN_MPL2_ONLY -DEIGEN_STACK_ALLOCATION_LIMIT=16384 -I../../SomePath -I../../SomePath2 -isystem ../../path_to/include/Eigen -m64 -stdlib=libc++ -g -fPIC -std=c++11 -MD -MT a_file.cpp.o -MF a_file.cpp.o.d -o a_file.cpp.o -c a_file.cpp
../../path_to/include/Eigen/Eigen/src/Core/Swap.h:89:36: error: Assigned value is garbage or undefined [clang-analyzer-core.uninitialized.Assign,-warnings-as-errors]
a_file.cpp:279:5: note: Loop condition is true. Entering loop body
for( unsigned int i = 0; i < 100; ++i )
^
a_file.cpp:282:13: note: Calling move assignment operator …
Run Code Online (Sandbox Code Playgroud)