CLANG-CHECK(1)
π NAME π
okay bestie, gather round π«Ά because this is the manual page for clang-check β and yeah, the page literally calls itself "manual page for clang-check 20", that's the whole name, no notes π
also it's a User Commands page, which means it's section 1 of the manual. so when you see CLANG-CHECK(1) floating around out there in the wild, that's just this page's government name β¨
π DESCRIPTION π
so here's the whole vibe of how you call this thing:
USAGE: clang-check [options] <source0> [... <sourceN>]
options in, source files in, let's go β¨ (and that's source0 all the way through sourceN, forever and ever, no cap).
and then, because the DESCRIPTION section is where the options live, here they all are ππ
π§Έ OPTIONS
π Generic Options
--helpβ displays the available options π«Ά (and psst,--help-hiddengets you more)--help-listβ displays the list of available options (again,--help-list-hiddenif you want more π)--versionβ displays the version of this program, so you always know which era of clang-check you're in β
π clang-check options
--analyzeβ run the static analysis engine π₯--analyzer-output-path=<string>β write output to <file>--ast-dumpβ build the ASTs and then debug dump them--ast-dump-filter=<string>β use this with-ast-dumpor-ast-printto dump/print only the AST declaration nodes that have a certain substring in a qualified name. and if you wanna see every filterable declaration node name? use-ast-listπ―--ast-listβ build the ASTs and print the list of declaration node qualified names--ast-printβ build the ASTs and then pretty-print them π pretty print?? we love a glow-up--extra-arg=<string>β an additional argument to append to the compiler command line--extra-arg-before=<string>β an additional argument to prepend to the compiler command line (note the difference bestie, one goes on the end, one goes on the front π§)--fix-what-you-canβ apply fix-it advice even in the presence of unfixable errors π it's giving "we do what we can"--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
so about that build path, because this part is lowkey important:
-p <build-path> is what you use 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, iykyk). and when no build path is specified? it goes hunting β a search for compile_commands.json will be attempted through all parent paths of the first input file π
want an example of setting up Clang Tooling on a source tree? here:
https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
and now, <source0> ... β these specify the paths of source files π«Ά these paths are looked up in the compile command database, and there are rules, so pay attention:
- 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. periodt π
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: path/in/subtree and the current directory should follow the rules described above π don't skip that part bestie, it will bite you πΈ
okay that's the whole page!! this was clang-check 20, from September 2026, and the footer over there is still yelling CLANG-CHECK(1) at us π go forth and dump some syntax trees, you absolute icon ππ¦
π¦ where this page comes from
- ubuntu stonking: clang-tools-20 1:20.1.8-2ubuntu13 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms