CLANG-QUERY(1)
πΈ NAME πΈ
clang-query β bestie, it's literally the manual page for clang-query (version 21), and we're gonna get you fluent in it π
β¨ DESCRIPTION β¨
Okay so here's the vibe, fr fr. The usage is:
clang-query [options] <source0> [... <sourceN>]
And now the options, which is the part you actually came for π«Ά
π OPTIONS π
π Generic Options
--helpβ shows you all the available options (and if you add--help-hiddenyou get even more, iykyk)--help-listβ shows you a straight-up list of the available options (--help-list-hiddenunlocks the secret extra ones too)--versionβ prints the version of this program, no cap
π clang-query options
-c <command>β tell it exactly which command to run--extra-arg=<string>β an extra argument that gets appended to the compiler command line--extra-arg-before=<string>β same energy but it gets prepended to the compiler command line-f <file>β read your commands from a file-p <string>β build path β¨--preload=<file>β preload commands from a file and then go straight into interactive mode, main character behavior--use-colorβ use colors in detailed AST output. If it's not set, then colors will still be used if the terminal connected to standard output supports colors. So like, it's giving optional π
π§ the -p <build-path> situation
So -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 sitting in it β and heads up, you get that output by using the CMake option -DCMAKE_EXPORT_COMPILE_COMMANDS=ON. When no build path is specified, it will try to search for compile_commands.json through all the parent paths of the first input file. And if you want an example of setting up Clang Tooling on a source tree, it's right here: https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
π¦ and the <source0> ... part
<source0> ... β this is where you specify the paths of your source files, bestie. These paths get looked up in the compile command database. Real talk on the rules though:
- If the path of a file is absolute, it needs to point into CMake's source tree.
- If the path is relative, then 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.
- Any
"./"prefixes in the relative files get automatically removed β but the rest of a relative path must be a suffix of a path in the compile command database.
no cap, those path rules are strict. read them twice π
and that's the whole page, periodt π this was clang-query 21, dated September 2026, brought to you under CLANG-QUERY(1) β slay, go query some clang πβ¨
π¦ where this page comes from
- ubuntu stonking: clang-tools-21 1:21.1.8-10ubuntu2 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms