CLANG-QUERY(1)
β¨ NAME β¨
clang-query β it's literally the manual page for clang-query 22, except now it's written by someone who actually wants you to win π«Ά
π¦ DESCRIPTION π¦
okay bestie, here's the whole vibe. This is how you run it:
USAGE: clang-query [options] <source0> [... <sourceN>]
That's the shape of it, and everything else below is just the options. Let's go.
πΈ OPTIONS πΈ
β¨ Generic Options β¨
These ones are the universal, everyone-gets-them options. Very main character, very available.
--helpβ shows you all the available options. And if you're nosy (respect), there's--help-hiddenfor more π--help-listβ prints out the list of available options. Same deal as above:--help-list-hiddengets you more.--versionβ tells you which version of this program you're running. Iconic for bug reports.
π clang-query options π
These are the ones that are actually clang-query's own. The real ones.
-c <command>β specify a command to run. Just hand it what you want and go.--extra-arg=<string>β an additional argument to append to the compiler command line. It goes at the end, bestie.--extra-arg-before=<string>β an additional argument to prepend to the compiler command line. Same energy, but it goes first.-f <file>β read commands from a file. Not me avoiding typing by putting everything in a file π-p <string>β build path. (The full lore on this one is right below, keep reading.)--preload=<file>β preload commands from a file and start interactive mode. Basically: get a head start, then chat.--use-colorβ use colors in the detailed AST output. If it's not set, colors will be used if the terminal connected to standard output supports colors. So like... it's vibes-based by default. π
π THE -p BUILD PATH TEA π
-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. Yes, that's the whole trick. β¨
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 an actual example of setting up Clang Tooling on a source tree, the docs are here: https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html
π THE SOURCE FILES π
<source0> ... β this is where you specify the paths of source files.
These paths are looked up in the compile command database. And the rules are kinda specific, so listen up because this is the part people get wrong π:
- 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 last bullet is the vibe check that fails people. read it twice. π
and that's the page, bestie!! π this was clang-query 22, dated September 2026 β go forth and query some clang, you absolute queen πβ¨
π¦ where this page comes from
- ubuntu stonking: clang-tools-22 1:22.1.8-1ubuntu1 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms