CLANG-CHECK(1)
π NAME π
okay bestie, say hi to clang-check β it's the manual page for clang-check 19, and we're gonna read it together, no cap. π¦
β¨ DESCRIPTION β¨
so here's the vibe, the whole entire usage in one little line:
USAGE: clang-check [options] <source0> [... <sourceN>]
and then it's OPTIONS o'clock. π
πΈ Generic Options πΈ
the "everyone gets these" squad, the basics, the little black dress of flags:
--helpβ shows you all the available options. and if that's not enough for you (iconic behaviour tbh), there's--help-hiddenfor the extra secret ones. π--help-listβ prints out a whole list of the available options. and yes, there's a--help-list-hiddenversion too for the ones that don't want to be seen. π--versionβ tells you which version of this program you're running. identity check, love that for you. β¨
π clang-check options π
the main character flags, the ones with main character energy:
--analyzeβ runs the static analysis engine. it's giving detective. π--analyzer-output-path=<string>β writes the output to<file>. put it where you want it bestie. π--ast-dumpβ builds ASTs and then debug-dumps them. raw, unfiltered, no editing. π--ast-dump-filter=<string>β use this alongside-ast-dumpor-ast-printto dump/print only the AST declaration nodes that have a certain substring in a qualified name. and if you wanna know what you can even filter by, hit-ast-listto list all the filterable declaration node names. so helpful, so organized. π§--ast-listβ builds ASTs and prints out the list of declaration node qualified names. a whole roster. π--ast-printβ builds ASTs and then pretty-prints them. glow-up, but for code. β¨--extra-arg=<string>β an extra argument to append to the compiler command line. add it at the end, like a little garnish. π--extra-arg-before=<string>β an extra argument to prepend to the compiler command line. this one goes first, front of the line, VIP. π--fix-what-you-canβ applies fix-it advice even when there are unfixable errors in the mix. do what you can, we respect the effort. π«Ά--fixitβ applies fix-it advice to the input source. it's literally fixing it for you. slay. π-p <string>β build path. (more on this below, don't scroll away bestie β¬οΈ)--syntax-tree-dumpβ dumps the syntax tree. π³--tokens-dumpβ dumps the preprocessed tokens. ποΈ
π¦ all about that build path, -p <build-path> π¦
okay so -p <build-path> is what you use to read a compile command database. no cap, that's the whole job.
for example, it can be a CMake build directory where a file named compile_commands.json lives. and if you need that file to exist, you get it by using the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON CMake option. that's the output you want. π
and here's the cute part: when you don't specify a build path, it'll go hunting for compile_commands.json through all the parent paths of the first input file. a little scavenger hunt. π
wanna see an example of setting up Clang Tooling on a source tree? it's right here:
https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
π the source files, <source0> ... π
<source0> ... specifies the paths of source files. and these paths get looked up in the compile command database. here are the rules, and yes you have to follow them:
- 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 get automatically removed. but the rest of a relative path must be a suffix of a path in the compile command database. no shortcuts, bestie. π
so, for example, to run clang-check on all files in a subtree of the source tree, you'd do:
find path/in/subtree -name '*.cpp'|xargs clang-check
or, if you want to use a specific build path:
find path/in/subtree -name '*.cpp'|xargs clang-check -p build/path
β οΈ note that path/in/subtree and the current directory should follow the rules described above. don't skip this part, it matters fr fr. π
okay that's the whole page! clang-check 19, brought to you June 2025. thanks for reading, you ate that. go run some checks, periodt. π β¨ππ¦
π¦ where this page comes from
- debian bookworm: clang-tools-19 1:19.1.7-3~deb12u1 Β· APACHE-2-LLVM-EXCEPTIONS
- debian trixie: clang-tools-19 1:19.1.7-3+b1 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms