CLANG-CHECK(1)
π
clang-check β the manual page for clang-check 17 β¨
okay bestie, welcome to the group chat, pull up a chair π«Ά this is the manual page for clang-check 17, and I'm gonna walk you through it like we're texting at 2am. no cap, every single flag is staying right here. let's get into it π
πΈ NAME πΈ
clang-check β literally the manual page for clang-check 17, that's it, that's the name, periodt π
π¦ DESCRIPTION π¦
here's how you run it, okay? the usage vibe is:
USAGE: clang-check [options] <source0> [... <sourceN>]
and then we have OPTIONS, which is giving very much main character energy, so let's go π
β¨ Generic Options β¨
the basics, the essentials, the ones everyone needs π
--helpβ shows you all the available options (and if you want even more, there's--help-hiddenπ)--help-listβ prints out a list of the available options (and yeah,--help-list-hiddenexists too if you wanna go feral)--versionβ tells you which version of this program you're running, iconic
π clang-check options π
this is the good stuff, the real ones, the flags that do the thing π₯
--analyzeβ runs the static analysis engine, like it's putting your code under a microscope π¬--analyzer-output-path=<string>β writes the output to<file>, so you can yeet it somewhere specific--ast-dumpβ builds up those ASTs and then debug-dumps them, very raw, very real--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 all the filterable declaration node names, use-ast-listfor that π--ast-listβ builds ASTs and prints out the list of declaration node qualified names--ast-printβ builds ASTs and then pretty-prints them, so they're all dressed up and cute π--extra-arg=<string>β an extra argument that gets appended to the compiler command line--extra-arg-before=<string>β an extra argument that gets prepended to the compiler command line (yes, before, it goes first, it's the main character of arguments)--fix-what-you-canβ applies fix-it advice even when there are unfixable errors hanging around. like, it's doing its best okay π--fixitβ applies fix-it advice to the input source-p <string>β build path, that's the vibe--syntax-tree-dumpβ dumps the syntax tree--tokens-dumpβ dumps the preprocessed tokens
π§ the build path situation π§
so -p <build-path> is what you use to read a compile command database, got it? π
for example, it can be a CMake build directory where a file named compile_commands.json lives (use the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON CMake option to get that output, bestie, that's the whole trick). and when no build path is specified, it'll try to search for compile_commands.json through all the parent paths of the first input file. lowkey convenient, highkey useful.
and if you want an example of setting up Clang Tooling on a source tree, it's right here: https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html β go look, iykyk π«Ά
π source files, the rules, no cap π
<source0> ... is where you specify the paths of your source files. these paths get looked up in the compile command database. and here's the deal, okay, listen up:
- 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.
fr fr, those rules are strict. the path has to line up exactly, no wiggle room π
β examples, because we love a demo β
wanna run clang-check on all the files in a subtree of the source tree? say less:
find path/in/subtree -name '*.cpp'|xargs clang-check
or, if you're using a specific build path, do it like this:
find path/in/subtree -name '*.cpp'|xargs clang-check -p build/path
and note β path/in/subtree and the current directory should follow the rules described above π don't skip the rules, they will humble you π
heads up bestie: those find-and-xargs examples are exactly as written. copy them character for character and you're golden β¨
π a cute little sign-off π
and that's the whole page, you ate that π this manual is for clang-check 17, dated June 2025, and that's a wrap. go forth, check your clang, be the main character of your own source tree ππ¦π
π¦ where this page comes from
- debian trixie: clang-tools-17 1:17.0.6-22+b2 Β· APACHE-2-LLVM-EXCEPTIONS
- ubuntu questing: clang-tools-17 1:17.0.6-22build1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms