[cfe-dev] Fetching typedef details via libclang
Douglas Gregor
dgregor at apple.com
Mon Apr 11 17:15:41 PDT 2011
On Mar 28, 2011, at 1:55 PM, Stefan Seefeld wrote:
> I'm looking for a way to query the libclang AST whether a typedef's
> referree type was constructed in-place, such as in
>
> typedef struct { ... } CXString;
>
>
> Such constructs are rather common in C APIs, and I'd like to fold the
> two types (the anonymous struct with the 'CXString' alias) into one, to
> reduce the noise in the generated API documentation.
>
> Is this possible, using libclang ?
Not currently.
> If not, any ideas how best to
> implement that ?
It's a little tricky, because Clang's AST doesn't really hold on to this information well. In this specific case, where the tag is anonymous, you can query TagDecl::getTypedefForAnonDecl() to see if it's a typedef of an anonymous declaration. But in a similar case like
typedef struct CXString { ... } CXString;
the AST doesn't have the information you seek. Perhaps this information could be added into ElaboratedType or ElaboratedTypeLoc.
- Doug
More information about the cfe-dev
mailing list