CLANG-CHECK(1)

πŸ“¦
version 16.0.6 Β· 2 versions
, in debian bookworm

πŸ‘‘ CLANG-CHECK β€” the manual page, bestie edition πŸ’…

okay so real talk, this is the manual page for clang-check from the User Commands girlies, version 16. she's that girl. let's get into it 🫢


✨ NAME ✨

clang-check β€” manual page for clang-check 16 πŸŽ€


🌸 DESCRIPTION 🌸

USAGE:

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

OPTIONS:


πŸ¦‹ Generic Options πŸ¦‹

  • --help β€” shows you all the available options. and if you're nosy (same bestie, same) add --help-hidden for even more πŸ‘€
  • --help-list β€” shows you a list of the available options. and again, --help-list-hidden if you wanna see the hidden ones too πŸ™ˆ
  • --version β€” tells you which version of this program you're running. icon behaviour fr ⭐

πŸ’– clang-check options πŸ’–

  • --analyze β€” runs the static analysis engine πŸ”₯
  • --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 use -ast-list to list all the filterable declaration node names, iykyk πŸ”
  • --ast-list β€” builds ASTs and prints the list of declaration node qualified names πŸ“‹
  • --ast-print β€” builds ASTs and then pretty-prints them. pretty-privilege ✨
  • --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 ⬅️
  • --fix-what-you-can β€” applies fix-it advice even when there are unfixable errors hanging around 🩹
  • --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 build path lore 🌈

-p <build-path> is what you use to read a compile command database.

so for example, it can totally be a CMake build directory where a file named compile_commands.json exists. (use the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON CMake option to get this output, bestie πŸ’…). and when no build path is specified, a search for compile_commands.json will be attempted through all parent paths of the first input file.

if you want an example of setting up Clang Tooling on a source tree, it's here:

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


πŸ“ the source files πŸ“

<source0> ... specify the paths of source files. no cap, these paths are looked up in the compile command database. so here's the tea:

  • 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 πŸ’…


🧚 examples, because we love a demo 🧚

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 the current directory should follow the rules described above. don't skip the rules, they're the rules 😭

and that's the whole page, bestie. main character manual energy only πŸ‘‘

signing off: clang-check 16, October 2023, CLANG-CHECK(1) β€” mwah, take care of yourselves πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from