CLANG-CHECK(1)

πŸ“¦
version 13.0.1 Β· 3 versions
, in ubuntu jammy

✨ NAME ✨

okay so this is the manual page for clang-check β€” bestie, it's literally the clang-check 13 era. πŸ’…


🌸 DESCRIPTION 🌸

USAGE, babes:

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

OPTIONS: πŸ‘‘

πŸŽ€ Generic Options πŸŽ€

  • --help β€” shows you all the available options (and if you want even more, there's --help-hidden)
  • --help-list β€” prints a whole list of the available options (and yep, --help-list-hidden exists for the extra ones too)
  • --version β€” tells you the version of this program, iconic

πŸ¦‹ clang-check options πŸ¦‹

  • --analyze β€” runs the static analysis engine πŸ”₯
  • --ast-dump β€” builds the ASTs and then debug-dumps them
  • --ast-dump-filter=<string> β€” use this with -ast-dump or -ast-print to only dump/print AST declaration nodes that have a certain substring in their qualified name. Use -ast-list to list all the filterable declaration node names πŸ‘€
  • --ast-list β€” builds ASTs and prints the list of declaration node qualified names
  • --ast-print β€” builds ASTs and then pretty-prints them ✨
  • --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
  • --fix-what-you-can β€” applies fix-it advice even when there are unfixable errors present (fix what you can, periodt)
  • --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

-p <build-path> is what you use to read a compile command database. πŸ—‚οΈ

For example, it can totally be a CMake build directory that has a file named compile_commands.json living in it (use the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON CMake option to get that output, bestie). If you don't specify a build path, it'll go hunting for compile_commands.json through every parent path 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. 🫢

<source0> ... these are where you specify the paths of your source files. The paths get looked up in the compile command database. If a file's path is absolute, it needs to point into CMake's source tree. If the path is relative, then the current working directory needs to be inside the CMake source tree, and the file has to be in a subdirectory of the current working directory. Any "./" 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. 😭

For example, to run clang-check on every file in a subtree of the source tree, use:

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
Note, that path/in/subtree and the current directory should follow the rules described above. ⭐

and that's the whole vibe, bestie πŸ’– this was clang-check 13, dated July 2023, and yeah β€” main character manpage energy, we ate and left no crumbs πŸ‘‘πŸŒˆ

πŸ“¦ where this page comes from