CLANG-QUERY(1)

πŸ“¦ version 11.1.0, in ubuntu jammy

πŸ’– NAME πŸ’–

clang-query β€” bestie, it's the manual page for clang-query 11, and it's about to be your new fave 🫢


✨ DESCRIPTION ✨

okay so here's the whole vibe, the usage line first because that's the main character:

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

and then the options, yes ALL of them, we are not skipping a single one πŸ’…

🌸 Generic Options 🌸

  • --help β€” shows you the available options (--help-hidden if you want the extra secret ones too πŸ‘€)
  • --help-list β€” shows you a list of the available options (--help-list-hidden for more)
  • --version β€” tells you what version of this program you're running

πŸŽ€ clang-query options πŸŽ€

  • -c=<command> β€” specify a command to run
  • --extra-arg=<string> β€” an extra argument to append to the compiler command line
  • --extra-arg-before=<string> β€” an extra argument to prepend to the compiler command line
  • -f=<file> β€” read commands from a file
  • -p=<string> β€” build path
  • --preload=<file> β€” preload commands from a file and then start interactive mode ✨

πŸ¦‹ the -p build path situation πŸ¦‹

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

for example, it can be a CMake build directory where a file named compile_commands.json exists β€” and to get that output you use the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON CMake option πŸ’‘

when no build path is specified, a search for compile_commands.json will be attempted through all parent paths of the first input file. see: https://clang.llvm.org/docs/HowToSetupToolingForLLVM.html for an example of setting up Clang Tooling on a source tree.

πŸ“ the <source0> ... situation πŸ“

<source0> ... specify the paths of source files. these paths are looked up in the compile command database. πŸ—‚οΈ

  • 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.

bestie real talk: that last bit about relative vs absolute paths is the part that eats people alive 😭 read it twice, i'm literally begging πŸ™ˆ

and that's the whole page, no cap πŸ‘‘

signing off with the deets: this is clang-query 11, dated January 2022, and it's living under CLANG-QUERY(1) in the User Commands section of the manual. slay, go query some clang πŸ’œβœ¨

πŸ“¦ where this page comes from