I am trying to find how to use a matcher with clang-query using the CXXMemberCallExpr
I've tried various case permutations and cannot get it to work. It appears that the first char is lower cased compared to the dump so eg FunctionDecl becomes functionDecl in clang-query
It would be nice if the -ast-dump matcher names matched the clang-query names - but guess they don't
eg.
clang-query> match CXXMemberCallExpr()
1:2: Matcher not found: CXXMemberCallExpr
clang-query> match cxxmemberCallExpr()
1:2: Matcher not found: cxxmemberCallExpr
clang-query> match CxxMemberCallExpr()
1:2: Matcher not found: CxxMemberCallExpr
clang-query> match CXXmemberCallExpr()
1:2: Matcher not found: CXXmemberCallExpr
clang-query> match cxxMemberCallExpr()
1:2: Matcher not found: cxxMemberCallExpr
If people wanted to help more I wanted to create a matcher to Virtual::foo(), so all calls to base class virtual function.
This is the code that I was trying to use
class Virtual
{
public:
virtual void foo()
{
}
};
class Real : public Virtual
{
public:
virtual void foo()
{
}
};
void bar()
{
Virtual *v=new Real();
Real *r=new Real();
Virtual *v2=new Virtual();
v->foo();
r->foo();
v2->foo();
delete v;
delete r;
delete v2;
}
And command for clang for the full AST (too long to paste) clang -Xclang -ast-dump virt.cc
I have yet not used clang-query, but I am currently looking up on how to use it for my own project.
Looking at the ASTMatcher reference I think the function you want to use is memberCallExpr()
. CXXMemberCallExpr
is a type and i don't think it is used in the queries.