CLANG-QUERY(1)
π
CLANG-QUERY β the clang-query(1) page, but make it make sense
okay bestie, welcome to the User Commands corner of the manual, and yes, this is the whole entire vibe of clang-query. it's giving "AST query tool that runs your little commands," and honestly? iconic.
β¨ NAME β¨
clang-query β manual page for clang-query 13 π
πΈ DESCRIPTION πΈ
so here's the tea, fr fr β this is how you run it:
USAGE: clang-query [options] <source0> [... <sourceN>]
and now the options, which we are going to go through one by one, no skipping, because every single one matters π
π OPTIONS π
β Generic Options β
--helpβ shows you all the available options. (there's also--help-hiddenif you want the extra secret menu, no cap π)--help-listβ prints out a whole list of the available options. (and yeah,--help-list-hiddenexists too, for the hidden ones π)--versionβ tells you which version of this program you're running. slay.
π¦ clang-query options π¦
-c=<command>β pick 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 (yes, before, not after, the order is the whole point π«Ά)-f=<file>β read commands from a file π-p=<string>β build path--preload=<file>β preload commands from a file and then start interactive mode π--use-colorβ use colors in the detailed AST output. and if you don't set it, colors get used anyway when the terminal connected to standard output supports colors π lowkey automatic, highkey cute
π the -p lore π
-p <build-path> is how you read a compile command database. that's the whole job, bestie.
for example, it can be a CMake build directory that has a file named compile_commands.json sitting in it β use the -DCMAKE_EXPORT_COMPILE_COMMANDS=ON CMake option to get that output. and when no build path is specified at all? 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. iykyk π
π§ the <source0> situation π§
<source0> ... β this is where you specify the paths of source files. these paths are looked up in the compile command database, and there are rules, bestie, so listen up:
- 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. periodt.
okay genuine warning vibes though: that path stuff is not a suggestion, it's the actual contract. if your relative path isn't a suffix of a path in the compile command database, it's not gonna work, and no amount of manifesting will fix it π
and that's the page, bestie!! every flag, every path rule, every word, all of it π
this was clang-query 13, dated July 2023 β main character energy, absolutely ate, no crumbs left πβ¨ bye!! π¦
π¦ where this page comes from
- ubuntu jammy: clang-tools-13 1:13.0.1-2ubuntu2.2 Β· APACHE-2-LLVM-EXCEPTIONS
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms