CLANG-CHECK(1)

πŸ“¦
version 20.1.8 Β· 4 versions
, in ubuntu stonking

πŸ’– 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-hidden gets you more)
  • --help-list β€” displays the list of available options (again, --help-list-hidden if 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-dump or -ast-print to 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