[cfe-dev] Type exploration in clang AST

Olivier olivier.grant at gmail.com
Mon Dec 13 04:03:36 PST 2010


Hi,

I'm trying to figure out how to extract information from the Type classes 
hierarchy but I'm bumping into a few problems.

Given a template instantiation TI - that would be represented by a 
clang::TemplateSpecializationType node - I'm trying to determine if any of the 
template arguments of TI are used as a member or a base class of TI.

But I can't seem to figure out how to get that information from a 
clang::TemplateSpecializationType.


void process( clang::TemplateSpecializationType const *pType )
{
  // Get the associated template declaration.
  clang::TemplateDecl const *pDecl
    = pType->getTemplateName().getAsTemplateDecl();
  
  if(pDecl)
  {
    // Get the templated record associated to the template specialization.
    clang::CXXRecordDecl const *pRecD
      = cast<clang::CXXRecordDecl>(pDecl->getTemplatedDecl());
    
    // Get a pointer to the instantiation arguments array.
    clang::TemplateArgument const *pArgs = pType->getArgs();
    
    // Get the size of the instantiation arguments array.
    unsigned nbArgs = pType->getNumArgs();
  }
}

How with this information can I now get the complete types of all base classes 
and members of the type represented by 'pType' ?

Thanks for your time,

Olivier.





More information about the cfe-dev mailing list