sammccall added a comment.
In D56444#1351056 <https://reviews.llvm.org/D56444#1351056>, @aaron.ballman
wrote:
> Given that, I kind of think we should have functionDecl() match only
> functions, and give users some other way to match the semantic declarations
> in a consistent manner. Alternatively, we could decide semantics are what we
> want to match (because it's what the AST encodes) and instead we give users a
> way to request to only match syntax.
I believe matching the implied semantic nodes is how closer to how matchers
behave in general (corresponding to the fact that the ASTMatcher
RecursiveASTVisitor sets `shouldVisitImplicitCode` to true). e.g.
$ cat ~/test.cc
void foo() { for (char c : "abc") {} }
$ bin/clang-query ~/test.cc --
clang-query> set output detailed-ast
clang-query> match binaryOperator()
Match #1:
Binding for "root":
BinaryOperator 0x471f038 </usr/local/google/home/sammccall/test.cc:1:26>
'_Bool' '!='
|-ImplicitCastExpr 0x471f008 <col:26> 'const char *':'const char *'
<LValueToRValue>
| `-DeclRefExpr 0x471efc8 <col:26> 'const char *':'const char *' lvalue Var
0x471ed48 '__begin1' 'const char *':'const char *'
`-ImplicitCastExpr 0x471f020 <col:26> 'const char *':'const char *'
<LValueToRValue>
`-DeclRefExpr 0x471efe8 <col:26> 'const char *':'const char *' lvalue Var
0x471edb8 '__end1' 'const char *':'const char *'
etc
Obviously this is only true when such nodes are present in the AST at the time
of matching (if I'm understanding Manuel's comment correctly).
Repository:
rC Clang
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D56444/new/
https://reviews.llvm.org/D56444
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits