我无法让 clang-tidy 读取我的编译数据库。如果我尝试:
clang-tidy --config-file ./.clang-tidy -checks=* -p ./target
Run Code Online (Sandbox Code Playgroud)
或者
clang-tidy --config-file ./.clang-tidy -checks=* -p ./target/compile-commands.json
Run Code Online (Sandbox Code Playgroud)
我明白了
Error: no input files specified.
USAGE: clang-tidy [options] <source0> [... <sourceN>]
...
Run Code Online (Sandbox Code Playgroud)
但根据 --help -p 的方式来指定它的路径。它似乎只有在我指定单个文件时才有效,如下所示:
clang-tidy --config-file ./.clang-tidy -checks=* path/to/file.cpp
Run Code Online (Sandbox Code Playgroud)
当您说“根据 --help -p 是指定它的路径的方法”时,我认为您指的是 Clang -Tidy页面中的这段文字:
-p <build-path> is used to read a compile command database.
For example, it can be a CMake build directory in which a file named
compile_commands.json exists (use -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
CMake option to get this output). When no build path is specified,
a search for compile_commands.json will be attempted through all
parent paths of the first input file . See:
https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html for an
example of setting up Clang Tooling on a source tree.
Run Code Online (Sandbox Code Playgroud)
正如它所说,-p帮助clang-tidy找到编译数据库,它告诉clang-tidy如何编译列出的源文件,但它实际上并没有指定要分析哪些文件。(一般来说,数据库可以说明如何编译很多东西,但您可能只想分析其中的一个子集。)
要指定要分析的内容,您必须在命令行上的选项后面列出所有文件名。也许不幸的是,没有办法要求clang-tidy分析编译数据库中的所有内容。
| 归档时间: |
|
| 查看次数: |
1977 次 |
| 最近记录: |