CLANG-CHECK(1)
π CLANG-CHECK(1) π
ok so bestie, this is the manual page for clang-check β it lives in the User Commands section of the manual, and it's giving "compiler tooling but make it β¨fancyβ¨". buckle up, we're going in π
πΈ NAME πΈ
clang-check β manual page for clang-check 15 π¦
β¨ DESCRIPTION β¨
ok so here's the whole vibe, the entire usage of this thing, no cap:
USAGE: clang-check [options] <source0> [... <sourceN>]
and nowβ¦ OPTIONS π (yes we're doing options, yes there are a lot, yes we're doing all of them)
π Generic Options π
these are the basics, the everyday essentials, the main character options fr:
--helpβ shows you the available options. and if you want even more, there's--help-hiddenfor that π--help-listβ shows you the list of available options. and yep, there's--help-list-hiddenfor even more of them too π«Ά--versionβ tells you the version of this program, iconic behaviour honestly β
π¦ clang-check options π¦
the real ones, the ones you actually came here for:
--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-dumpor-ast-printto dump/print only AST declaration nodes having a certain substring in a qualified name. use-ast-listto 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 π (pretty-print!! she's literally named after us)--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 πΌ--fix-what-you-canβ apply fix-it advice even in the presence of unfixable errors. like, do what you can bestie, it's fine π--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 lore (build path) π§
so, -p <build-path> is used to read a compile command database. periodt.
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). 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 π
πΈ the <source0> ... source files situation πΈ
<source0> ... specify the paths of source files. these paths are looked up in the compile command database. no cap, here are the rules:
- 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.
π examples, because we love a demonstration π
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 π (yes, the rules we just went over, don't skip them bestie)
and that's the whole page!! π this was clang-check 15, dated July 2023 π thanks for reading, you ate that fr fr π«Άβ¨π
π¦ where this page comes from
- ubuntu jammy: clang-tools-15 1:15.0.7-0ubuntu0.22.04.3 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms