Open egraether opened 5 years ago
A personal use case: find all instance of a global variable access (in a embedded enviroment there are plenty).
in clang-query, i write a matcher somewhat like this:
match declRefExpr(hasDeclaration(varDecl(unless(hasAncestor(functionDecl())))))
which matches on the ast all the cases where the scope was accessed for a symbol, filter for the one declared as variables, and filter out those declared inside a function.
http://clang.llvm.org/docs/LibASTMatchersReference.html