CLANG-QUERY(1)
π NAME π
clang-query β bestie, it's the manual page for clang-query 11, and it's about to be your new fave π«Ά
β¨ DESCRIPTION β¨
okay so here's the whole vibe, the usage line first because that's the main character:
USAGE: clang-query [options] <source0> [... <sourceN>]
and then the options, yes ALL of them, we are not skipping a single one π
πΈ Generic Options πΈ
--helpβ shows you the available options (--help-hiddenif you want the extra secret ones too π)--help-listβ shows you a list of the available options (--help-list-hiddenfor more)--versionβ tells you what version of this program you're running
π clang-query options π
-c=<command>β specify a command to run--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-f=<file>β read commands from a file-p=<string>β build path--preload=<file>β preload commands from a file and then start interactive mode β¨
π¦ the -p build path situation π¦
so -p <build-path> is how you read a compile command database. fr fr.
for example, it can be a CMake build directory where 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. see: https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html for an example of setting up Clang Tooling on a source tree.
π the <source0> ... situation π
<source0> ... specify the paths of source files. these paths are 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.
"./"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.
bestie real talk: that last bit about relative vs absolute paths is the part that eats people alive π read it twice, i'm literally begging π
and that's the whole page, no cap π
signing off with the deets: this is clang-query 11, dated January 2022, and it's living under CLANG-QUERY(1) in the User Commands section of the manual. slay, go query some clang πβ¨
π¦ where this page comes from
- ubuntu jammy: clang-tools-11 1:11.1.0-6 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms