typedef, TagType & isDefinition() bug.

Code example:
---->
struct A;
typedef struct A B;
struct A { int a; };
----<

The second declaration is of type clang::TypeDecl,
using getUnderlyingType() I obtain the clang::QualType of the struct A.

getTypePtr() gives me the clang::RecordType.

But to know the name of the referenced struct (the `A') I need to use
getDecl().

getDecl() returns a pointer to the declaration, but this clang::RecordDecl's
isDefinition() member function returns true. I think this is a bug.

If not, how can I distinguish from this:
---->
struct A;
typedef struct A B;
struct A { int a; };
----<

to this?
---->
struct A;
typedef struct A { int a; } B;
----<

Thanks.
pb

Code example:
---->
struct A;
typedef struct A B;
struct A { int a; };
----<

The second declaration is of type clang::TypeDecl,
using getUnderlyingType() I obtain the clang::QualType of the struct A.

getTypePtr() gives me the clang::RecordType.

But to know the name of the referenced struct (the `A') I need to use
getDecl().

getDecl() returns a pointer to the declaration, but this clang::RecordDecl's
isDefinition() member function returns true. I think this is a bug.

RecordType::getDecl() always points at the definition (once we have a definition) so that we can efficiently get from a type to its definition. This is a relatively important ability, since many operations involve looking into the definition of a class type.

If not, how can I distinguish from this:
---->
struct A;
typedef struct A B;
struct A { int a; };
----<

to this?
---->
struct A;
typedef struct A { int a; } B;
----<

Right now, you can't. The work on DeclGroups---which is only partially complete in Clang---is meant to represent the second case. It currently deals with cases like, e.g.,

  int x, y; // both x and y are in the same DeclGroup

but doesn't deal with tag types like structs.

  - Doug