CLANG-CHECK(1)

πŸ“¦
version 22.1.8 Β· 3 versions
, in ubuntu stonking

πŸ’– 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-hidden if you want more, you nosy icon 🫢)
  • --help-list β€” Displays a list of the available options. (And --help-list-hidden for 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-dump or -ast-print to dump/print only AST declaration nodes having a certain substring in a qualified name. Use -ast-list to 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