CLANG-CHECK(1)

πŸ“¦
version 18.1.8 Β· 5 versions
, in debian trixie, ubuntu questing

🌸 clang-check β€” NAME πŸ’…

okay so bestie, clang-check is literally the manual page for clang-check 18. that's it, that's the name, and we're already slaying ✨


πŸ¦‹ DESCRIPTION

the whole vibe, in one line:

USAGE: clang-check [options] <source0> [... <sourceN>]

and now, the options. buckle up, there's a lot, but we're getting through this together 🫢

✨ Generic Options ✨

  • --help β€” shows you all the available options (and if you want even more chaos, there's --help-hidden for that)
  • --help-list β€” prints out a list of the available options (again, --help-list-hidden exists if you're feeling extra)
  • --version β€” tells you what version of this program you're on

πŸŽ€ clang-check options πŸŽ€

  • --analyze β€” runs the static analysis engine. it's giving detective energy πŸ”
  • --analyzer-output-path=<string> β€” writes the output to <file>
  • --ast-dump β€” builds ASTs and then debug dumps 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 need the list of all the filterable declaration node names, use -ast-list. iykyk πŸ’…
  • --ast-list β€” builds ASTs and prints the list of declaration node qualified names
  • --ast-print β€” builds ASTs and then pretty-prints them. pretty-print, pretty slay ✨
  • --extra-arg=<string> β€” an extra argument to append to the compiler command line
  • --extra-arg-before=<string> β€” an extra argument to prepend to the compiler command line (yes bestie, order matters, we love that for us)
  • --fix-what-you-can β€” applies fix-it advice even when there are unfixable errors hanging around. iconic resilience honestly
  • --fixit β€” applies fix-it advice to the input source
  • -p <string> β€” build path
  • --syntax-tree-dump β€” dumps the syntax tree
  • --tokens-dump β€” dumps the preprocessed tokens

🧚 the -p build path situation 🧚

-p <build-path> is what you use to read a compile command database. fr fr, that's its whole job.

for example, it can be a CMake build directory that has a file named compile_commands.json sitting in it (use the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON CMake option to get that output). when you don't specify a build path, it'll try to search for compile_commands.json through all the parent paths of the first input file. πŸ’«

want an example of setting up Clang Tooling on a source tree? here you go:

https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html


πŸ“ the source files πŸ“

<source0> ... is where you specify the paths of your source files. these paths get 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.

also, ./ prefixes in relative files get automatically removed β€” but the rest of a relative path has to be a suffix of a path in the compile command database. no cap, that's the rule πŸ“


🌈 examples, because we love a demonstration 🌈

say you wanna run clang-check on every file in a subtree of the source tree. do this:

find path/in/subtree -name '*.cpp'|xargs clang-check

or, if you wanna use a specific build path:

find path/in/subtree -name '*.cpp'|xargs clang-check -p build/path
heads up bestie β€” path/in/subtree and your current directory both need to follow the rules we just talked about up there. don't skip that part πŸ™ˆ

and that's the whole page!! go forth and check some clang, you absolute main character πŸ‘‘

this has been clang-check 18, from June 2025, signing off πŸ’œ ✨ πŸ¦‹

πŸ“¦ where this page comes from