CLANG-CHECK(1)
π NAME π
clang-check β the manual page for clang-check 22, bestie, and it's literally giving "I run static analysis on your C++ and I look cute doing it" β¨
π¦ DESCRIPTION π¦
Okay so, quick vibe check: here's how you call her π
clang-check [options] <source0> [... <sourceN>]
Now let's get into the OPTIONS, because there are a lot of them and they all eat π
πΈ Generic Options πΈ
These ones are the universal besties, every LLVM tool has them:
--helpβ Displays all the available options. (There's also--help-hiddenif you want more, you nosy icon π«Ά)--help-listβ Displays a list of the available options. (And--help-list-hiddenfor more, same energy as above π)--versionβ Displays the version of this program.
π clang-check options π
The main character options, no cap:
--analyzeβ Run the static analysis engine. π₯--analyzer-output-path=<string>β Write output to <file>.--ast-dumpβ Build ASTs and then debug dump them.--ast-dump-filter=<string>β Use with-ast-dumpor-ast-printto dump/print only AST declaration nodes having a certain substring in a qualified name. Use-ast-listto list all filterable declaration node names.--ast-listβ Build ASTs and print the list of declaration node qualified names.--ast-printβ Build ASTs and then pretty-print them. As she should π--extra-arg=<string>β Additional argument to append to the compiler command line.--extra-arg-before=<string>β Additional argument to prepend to the compiler command line. (Yeah, before, not after, don't mix them up π)--fix-what-you-canβ Apply fix-it advice even in the presence of unfixable errors. She tries her best fr fr π--fixitβ Apply fix-it advice to the input source.-p <string>β Build path.--syntax-tree-dumpβ Dump the syntax tree.--tokens-dumpβ Dump the preprocessed tokens.
π§ the -p build path situation π§
So: -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 the -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.
π and now: the source files π
<source0> ... specify the paths of source files. These paths are looked up in the compile command database. If the path of a file is absolute, it needs to point into CMake's source tree. If the path is relative, the current working directory needs to be in the CMake source tree and the file must be in a subdirectory of the current working directory. "./" prefixes in the relative files will be automatically removed, but the rest of a relative path must be a suffix of a path in the compile command database.
fr, read that paragraph twice, it's the one everyone gets wrong π
For example, to run clang-check on all files in a subtree of the source tree, use:
find path/in/subtree -name '*.cpp'|xargs clang-check
or using a specific build path:
find path/in/subtree -name '*.cpp'|xargs clang-check -p build/path
Note, that path/in/subtree and current directory should follow the rules described above. π
and that's the whole page, babe. this is clang-check 22, dated September 2026, and that's the tea β go forth and dump some ASTs, you absolute legend π©·πβ¨
π¦ where this page comes from
- ubuntu stonking: clang-tools-22 1:22.1.8-1ubuntu1 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms