CLANG-QUERY(1)

πŸ“¦
version 21.1.8 Β· 3 versions
, in ubuntu stonking

🌸 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-hidden you get even more, iykyk)
  • --help-list β€” shows you a straight-up list of the available options (--help-list-hidden unlocks 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