Per the tree the declRefExpr should have ImplicitCastExpr, CXXCtorInitializer and CXXConstructorDecl, but the parent list just lacks the initializer per the following query:
clang-query> match declRefExpr(hasParent(implicitCastExpr(hasParent(cxxConstructorDecl().bind('grandparent'))).bind("parent")))
Match #1:
C:\Users\sasch\Documents\GitHub\gecko-dev\build\clang-plugin\foo.cpp:3:3: note: "grandparent" binds here
Foo(int f): foo(f) {}
^~~~~~~~~~~~~~~~~~~~~
C:\Users\sasch\Documents\GitHub\gecko-dev\build\clang-plugin\foo.cpp:3:19: note: "parent" binds here
Foo(int f): foo(f) {}
^
C:\Users\sasch\Documents\GitHub\gecko-dev\build\clang-plugin\foo.cpp:3:19: note: "root" binds here
Foo(int f): foo(f) {}
^
1 match.
Given this code:
This does not match anything, although replacing
cxxCtorInitializer
withcxxConstructorDecl
matchesf
.Dumping AST via
clang-check -ast-dump
shows this tree:Per the tree the declRefExpr should have ImplicitCastExpr, CXXCtorInitializer and CXXConstructorDecl, but the parent list just lacks the initializer per the following query: