CLANG-CHECK(1)
π CLANG-CHECK π
okay so bestie, this is the manual page for clang-check, and she lives in section 1 of the manual β user commands, main character energy only. π
pull up a chair, grab a boba, we're going through every single flag together, and yes we're going through all of them, no skipping. π«Ά
π NAME π
clang-check β the manual page for clang-check 12 β¨
π¦ DESCRIPTION π¦
here's the whole vibe in one line, literally the entire synopsis, iconic:
clang-check [options] <source0> [... <sourceN>]
then it's justβ¦ options. a whole buffet of them. let's go π
π OPTIONS π
πΈ Generic Options πΈ
the everyday, everybody-gets-them options, no gatekeeping:
--helpβ displays the available options. and if you want even more, there's--help-hiddenπ--help-listβ displays the list of available options. and yeah,--help-list-hiddenexists for more π--versionβ displays the version of this program. flex it. π
π clang-check options π
okay this is the good part, the actual clang-check-specific stuff, she ate:
--analyzeβ runs the static analysis engine π₯--ast-dumpβ builds ASTs and then debug dumps them--ast-dump-filter=<string>β use this with-ast-dumpor-ast-printto dump/print only the AST declaration nodes that have a certain substring in a qualified name. and if you wanna know which declaration node names are even filterable, use-ast-listto list them all π§--ast-listβ builds ASTs and prints the list of declaration node qualified names--ast-printβ builds ASTs and then pretty-prints them (pretty!! as promised π)--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 (yes, before. order matters bestie π)--fix-what-you-canβ applies fix-it advice even in the presence of unfixable errors. she does what she can, okay?? πͺ--fixitβ applies fix-it advice to the input source-p=<string>β build path π
okay so about that last one, because -p is a whole situation:
-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 β and to get that output you use the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON CMake option. when no build path is specified, a search for compile_commands.json will be attempted through all parent paths of the first input file. and if you want a full example of setting up Clang Tooling on a source tree, it's right here: https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html β¨
π¦ about <source0> ... π¦
<source0> ... specify the paths of source files. these paths are looked up in the compile command database. now here's the rules, and she is strict:
- 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. no cap, that's the rule. π―
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. π don't skip this part, it WILL humble you.
and that's the whole page, bestie π we did it, we read every single line, nobody skipped the boring bits, we're so valid.
clang-check 12 β February 2022 β CLANG-CHECK(1) π«Ά bye ily, go compile something beautiful πβ¨
π¦ where this page comes from
- ubuntu jammy: clang-tools-12 1:12.0.1-19ubuntu3 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms