[cfe-dev] AST Matcher question -- hasAncestor
Riyaz Puthiyapurayil via cfe-dev
cfe-dev at lists.llvm.org
Wed Sep 21 11:03:55 PDT 2016
I am new to both clang AST Matchers. From an AST Matcher in a clang tidy check, what is the fastest way to get the enclosing function or method scope (if any) from a matching CallExpr node?
I tried something like this in clang-query and it seems to work as expected:
clang-query> match callExpr(hasAncestor(functionDecl().bind("contextFuncDef")).bind("someFuncCall")
But how does it work internally? Specifically, will it traverse up the AST to bind contextFuncDef every time callExpr is matched? That may be too expensive for my use. Or alternatively, does it save the matching ancestor in contextFuncDef as it descends down the AST?
Or the more general question would be: are matchers evaluated inside-out or outside-in or in some other way depending on the type of matcher. Is there any documentation outside of source code describing how matchers are implemented?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the cfe-dev