CLANG-QUERY(1)

πŸ“¦
version 18.1.8 Β· 5 versions
, in debian trixie, ubuntu questing

πŸ’… NAME πŸ’…

clang-query β€” bestie, it's literally the manual page for clang-query 18 ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

okay so. here's the vibe. you run it like this:

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

and then you get OPTIONS. yes that's literally the whole thing, she's a simple girlie πŸ’–


✨ OPTIONS ✨

🌸 Generic Options

  • --help β€” shows you the available options. want more? there's --help-hidden for that, no cap πŸ‘€
  • --help-list β€” prints out the list of available options (--help-list-hidden gets you even more)
  • --version β€” tells you which version of this program you're running πŸŽ€

🧚 clang-query options

  • -c <command> β€” name the command you want to run
  • --extra-arg=<string> β€” one more argument, and it gets appended to the compiler command line 🫢
  • --extra-arg-before=<string> β€” same energy but it gets prepended instead
  • -f <file> β€” read the commands straight out of file πŸ“„
  • -p <string> β€” build path
  • --preload=<file> β€” preload commands from file and then start interactive mode πŸ”₯
  • --use-color β€” colors in the detailed AST output. if you don't set it, colors still show up if the terminal connected to standard output supports colors. it's giving ✨ automatic ✨

🌈 the whole -p situation

-p <build-path> is how you read a compile command database. iykyk.

for example, it can be a CMake build directory with a file named compile_commands.json living in it (use the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON CMake option to get that output πŸ‘‘). and when you don't specify a build path at all? it goes hunting for compile_commands.json through all parent paths of the first input file. see:

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

that one's got an example of setting up Clang Tooling on a source tree, if you need it πŸ“


πŸ’€ the <source0> ... part

<source0> … you're specifying the paths of source files here. and these paths get looked up in the compile command database, periodt.

so: if a file's path is absolute, it needs to point into CMake's source tree. if the 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 on relative files get automatically removed πŸ™ˆ β€” but the rest of a relative path must be a suffix of a path in the compile command database. not optional, bestie.

fr fr, don't skip that last bit. relative paths are picky and she will not be flexible about it πŸ’…

that's the whole page, you ate it up 🌟 this was clang-query 18, dated June 2025, and it lives in the User Commands section of the manual β€” CLANG-QUERY(1), mwah πŸ˜­πŸ’– πŸ¦‹βœ¨πŸŽ€

πŸ“¦ where this page comes from