在BUILD 文件中增加一个用于生成 compile_commands.json 文件的 target load("@hedron_compile_commands//:refresh_compile_commands.bzl","refresh_compile_commands") refresh_compile_commands( name ="refresh_compile_commands",# 指
clang-tidy: 手动从 github.com/llvm/llvm-pr 下载了 LLVM-20.1.1-macOS-ARM64.tar.xz, 解压后的 bin 目录提供了 clang-tidy 可执行程序。 不使用 brew install llvm 因为觉得不好用。 准备如下测试代码, 原本打算查出其中未初始化问题; 生成 compile_commands.json 后, 发现 clang-tidy 报错说 cstdio 和...
结合compile_commands.json 使用 -p 参数指定 compile_commands.json 所在目录。 默认使用当前目录下的 .clang-tidy 文件。 clang-tidy-18 -p /home/zz/test/build /home/zz/test/main4.cpp zz@DESKTOP-P9FPHMA:~/test$ clang-tidy-18 -p /home/zz/test/build /home/zz/test/main4.cpp 1 warning gen...
clang-tidy可以使用compile_commands.json文件来获取编译命令的信息。你可以在这个文件中为特定的源文件添加编译选项,以忽略某些检查。例如: 代码语言:txt 复制 [ { "directory": "/path/to/project", "command": "clang++ -c /path/to/project/src/main.cpp", "file": "/path/to/project/src/main.cpp"...
sudo apt-get install clang-tidy macOS: bash brew install llvm Windows: 在Windows 下,clang-tidy.exe 通常随工具链发布,可以直接搜索到。2. 创建编译数据库 clang-tidy 需要一个编译数据库来了解如何编译你的代码。编译数据库通常是一个名为 compile_commands.json 的文件。你可以使用 CMake 来生成这个...
**绝对路径:** 绝对路径是指目录下的绝对位置,直接到达目标位置,通常是从盘符开始的路径。
ninja 来构建项目和 ninja -t compdb cc cxx > .build/compile_commands.json 来生成编译数据库。我试过运行: clang-tidy-3.6 -p .build/ \ $(find src/ -name *.cpp) \ $(find src/ -name *.hpp) \ --checks=misc-use-override --fix 修复错误。它拒绝触摸头文件抱怨:...
然后更新下Scons脚本,让生成compile_commands.json git diff SConstruct +env.Tool('compilation_db') +env.CompilationDatabase() make a building DoBuilding(TARGET, objs) run-clang-tidy 然后使用 run-clang-tidy 就可以自动分析所有的源代码了。
// compelie_commands.json 文件的目录位置(相对于工作区,由于 CMake 生成的该文件默认在 build 文件夹中,故设置为 build) "--compile-commands-dir=build" ], 注意compile-commands-dir项为编译目录,会在这下面生成clangd静态检查依赖编译数据库文件compelie_commands.json ...
分析项目中的y编译单元,clang-tidy首先要知道如何编译单元(该编译单元的编译命令),它从目录下查找compliation database,这个database就是compile_commands.json文件,里面包含该项目中所有的编译单元的编译命令。在使用之前要导出这个文件。目前已经有工具帮我们做了这项工作。