CLANG-QUERY(1)

πŸ“¦
version 14.0.6 Β· 5 versions
, in ubuntu questing

✨ NAME ✨

clang-query β€” bestie, it's literally a manual page for clang-query 14 πŸ¦‹


πŸ’– DESCRIPTION πŸ’–

okay so the whole vibe of this tool, first thing you gotta know:

USAGE: clang-query [options] <source0> [... <sourceN>]

and then, the OPTIONS:


🌸 OPTIONS 🌸

πŸŽ€ Generic Options πŸŽ€

these ones are the universal, everyone-gets-them options, no cap:

  • --help β€” shows you all the available options (and if you want the secret extra ones, hit --help-hidden instead) πŸ‘€
  • --help-list β€” prints out a list of the available options (same deal: --help-list-hidden for the hidden crowd) πŸ“‹
  • --version β€” tells you what version of this program you're running ✨

πŸ’… clang-query options πŸ’…

the ones that are actually about clang-query, periodt:

  • -c=<command> β€” say which command you want it to run
  • --extra-arg=<string> β€” an extra argument to tack onto the end of the compiler command line
  • --extra-arg-before=<string> β€” an extra argument to tack onto the front of the compiler command line
  • -f=<file> β€” read your commands from a file
  • -p=<string> β€” the build path
  • --preload=<file> β€” preload commands from a file, then drop straight into interactive mode 🫢
  • --use-color β€” use colors in the detailed AST output. If this isn't set, colors get used anyway if the terminal connected to standard output supports colors 🌈

πŸ› οΈ so about -p <build-path> πŸ› οΈ

-p <build-path> is how you read a compile command database. it's giving "here's where my build lives, go look" energy.

fr fr, for example: it can be a CMake build directory that has a file named compile_commands.json sitting in it (you get that output by using the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON CMake option). And when no build path is specified at all? it goes on a little scavenger hunt for compile_commands.json through all the parent paths of the first input file. πŸ”

want an example of setting up Clang Tooling on a source tree? it's right here, bestie:

https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html

πŸ“‚ <source0> ... β€” the source files πŸ“‚

<source0> ... is where you specify the paths of your source files.

those paths get looked up in the compile command database, and here's the tea:

  • 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.
  • any "./" prefixes in the 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.
lowkey important, highkey a vibe check for your paths β€” get this wrong and nothing resolves, bestie 😭

and that's the whole page, you ate it πŸ’–

this was clang-query 14, from May 2025 β€” go forth and query, icon πŸ‘‘βœ¨

πŸ“¦ where this page comes from