[cfe-dev] nodes not appearing in AST?

Robert Anderson rwa at alumni.princeton.edu
Fri Jan 6 11:37:11 PST 2012


It seems the AST generated by libclang is missing nodes in some cases.
Example:

The AST for the program:

struct A {
   void foo() {};
};

template <class T>
struct B {
   void bar();
   A m_a;
};

template <class T>
void B<T>::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 <class T>
struct A {
   void foo() {};
};

template <class T>
struct B {
   void bar();
   A<T> m_a;
};

template <class T>
void B<T>::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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20120106/9ee879e9/attachment.html>


More information about the cfe-dev mailing list