CLANG-QUERY(1)
β¨ NAME β¨
clang-query β okay bestie, this is literally the manual page for clang-query 20, and it sits in the User Commands corner of the manual (that's section 1, iykyk) π
π¦ DESCRIPTION π¦
So the whole vibe of this thing, right, is this:
USAGE: clang-query [options] <source0> [... <sourceN>]
And then it's just options all the way down. Not me listing every single one β I am listing every single one π«Ά
π OPTIONS π
π Generic Options:
--helpβ shows you the available options (and there's--help-hiddenif you want more, bestie)--help-listβ shows you the list of available options (and--help-list-hiddenfor more, again)--versionβ tells you the version of this program
π clang-query options:
-c <command>β say which command to run--extra-arg=<string>β an extra argument you want appended to the compiler command line--extra-arg-before=<string>β an extra argument you want prepended to the compiler command line (front of the line energy, iconic)-f <file>β read your commands from a file-p <string>β the build path--preload=<file>β preload commands from a file, then start interactive mode π§--use-colorβ use colors in the detailed AST output. But if you don't set it, colors get used anyway when the terminal connected to standard output supports colors. So basically it's a "you didn't have to ask, but go off" situation β¨
π the -p <build-path> of it all
-p <build-path> is what you use to read a compile command database.
For example, it can be a CMake build directory that has a file named compile_commands.json in it β and to get that file you use the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON CMake option. And when you don't specify a build path at all, it goes looking for compile_commands.json up through every parent path of the first input file. If you want an example of setting up Clang Tooling on a source tree, see https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html π
π¦ the <source0> ... of it all
<source0> ... is where you specify the paths of your source files. Those paths get looked up in the compile command database, and okay here's the part you actually need to hear:
- If a file's path is absolute, it needs to point into CMake's source tree.
- If a file's path is relative, then your current working directory needs to be in the CMake source tree, and the file has to be in a subdirectory of the current working directory.
Also, "./" 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, that's the rule π
And that's the whole page, angel. This was clang-query 20, dated September 2026 β go forth and query, you absolute main character, and remember: absolute paths point into the CMake source tree, relative paths need you standing in it π
π¦ where this page comes from
- ubuntu stonking: clang-tools-20 1:20.1.8-2ubuntu13 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms