[cfe-dev] Recovering pointer vs. reference typedefs from the AST

Kenneth Hill ken.j.hill at gmail.com
Tue May 29 13:14:29 PDT 2012


Consider the following simple header file processed with clang 3.0
with the "c++" option:

    struct Location
    {
    	double x, y;
    };

    typedef Location Loc;
    typedef Location *LocPtr;
    typedef Location &LocRef;

I can find nothing in the Python interface that differentiates the
cursor for Loc from LocPtr or LocRef (other than the location info).
In all three cases the cursor is of kind CursorKind.TYPEDEF_DECL, and
it's one child is of type CursorKind.TYPE_REF, from which I can use
get_definition() to find the cursor for struct Location.  But I can't
find a way to decide that Loc is a structure, LocPtr is a POINTER to a
structure, and LocRef is a REFERENCE to a structure.  The AST seems to
imply they are all identical typedefs.  Am I missing something?



More information about the cfe-dev mailing list