[cfe-dev] Questions about CXXRecordDecl

Alexander MacDonald alexmac at adobe.com
Sun Mar 13 14:12:43 PDT 2011


Hi, I'm writing a small clang plugin to inspect a codebase I work on and perform various custom semantic analyses. I've figured out most of what I need but I've run into a couple of small problems:

Given a CXXRecordDecl which represents an implicitly instantiated template class (mydecl->getTemplateSpecializationKind() == TSK_ImplicitInstantiation). I want to find the original unspecialized CXXRecordDecl / QualType. mydecl->getDescribedClassTemplate() is returning null, perhaps there's some functionality in Sema I should be using instead?

Given a CXXRecordDecl I want to print the class name along with all namespace qualifiers. doing a "->getDeclName().getAsString()" gives me something like "class foons::fooclass", I don't want the "class". I tried to use a PrintingPolicy with SupressTag=True but that seemed to suppress everything. I've written some code to walk up the declaring context chain to find all the enclosing namespace decls and this works just fine, but surely there's already some code to do this in clang.

Thanks,
Alex Mac



More information about the cfe-dev mailing list