Prerequisites include
- Installation of clang
- Existing of a compile_commands.json file in the root of the condor source tree. Note that cmake can produce this, and the default "configure_uw" script includes the command to generate this as a side-effect of compiling.
- An in-source build. I'm sure there's a way to work around this, but I haven't found it.
Given the above, clang-query can find source code matches when run like this
clang-query -f file_with_pattern source_file.cpp
The magic, of course, is in the pattern. Here is an example pattern that finds all calls to "reserve" from the vector class"
let bind-root true let m1 cxxMemberCallExpr( callee(cxxMethodDecl(hasName("reserve"))), thisPointerType(namedDecl(hasName("vector")))) m m1
In theory, clang-query can take an arbitrary number of source file arguments, but in my experience, it crashes after some large number, so I feed it files one at a time, grepping them out of the compile_commands.json database, like so
grep '"file":' compile_commands.json | tr -d '"' | awk '{print $2}' | xargs -n 1 clang-query -f findVectors