It seems the AST generated by libclang is missing nodes in some cases. Example:
The AST for the program:
struct A {
void foo() {};
};
template
struct B {
void bar();
A m_a;
};
template
void B::bar()
{
m_a.foo();
}
contains a CALL_EXPR node for the symbol foo, just as I expect:
% ./c-index-test -test-print-typekind test6.cxx > out
% grep foo out
CXXMethod=foo:3:9 (Definition) typekind=FunctionProto [result=Void] [isPOD=0]
CallExpr=foo:3:9 typekind=Dependent [isPOD=1]
MemberRefExpr=foo:3:9 SingleRefName=[15:8 - 15:11] RefName=[15:8 - 15:11] typekind=Unexposed [isPOD=1]
However, the program:
template
struct A {
void foo() {};
};
template
struct B {
void bar();
A m_a;
};
template
void B::bar()
{
m_a.foo();
}
where A is now a class template, does NOT contain such a node. The only node referencing foo is the declaration:
% ./c-index-test -test-print-typekind test5.cxx > out
% grep foo out
CXXMethod=foo:4:9 (Definition) typekind=FunctionProto [result=Void] [isPOD=0]
Can someone explain this? Is this a bug? How can I discover the “uses” of foo in this program if none of the nodes in the AST have that spelling?
Thanks,
Bob Anderson