[cfe-commits] [Patch][Review request] RecursiveASTVisitor can now traverse template specializations
Benoit Belley
Benoit.Belley at autodesk.com
Tue Aug 31 17:01:33 PDT 2010
I'll update to the latest revision then!
Benoit
> -----Original Message-----
> From: John McCall [mailto:rjmccall at apple.com]
> Sent: 31 août 2010 18:25
> To: Benoit Belley
> Cc: Yves Boudreault; Francesco Iorio; cfe-commits at cs.uiuc.edu
> Subject: Re: [cfe-commits] [Patch][Review request] RecursiveASTVisitor
> can now traverse template specializations
>
> On Aug 31, 2010, at 2:57 PM, Benoit Belley wrote:
> > I have made good progress today with the help of your comments.
>
> Glad to hear it!
>
> > Visiting the class template definition while skipping the re-
> declarations turns out to be not so obvious. FunctionDecl and VarDecl
> have isThisDeclarationADefiniton(). RecordDecl has getDefintion()...
> But, ClassTemplateDecl has none of this. I have found that the
> following trick seems to work in practice:
> >
> > ClassTemplateDecl* D = ...;
> > CXXRecordDecl* TemplDecl = D->getTemplatedDecl();
> > if (TemplDecl) {
> > if (CXXRecordDecl* TemplDef = TemplDecl->getDefinition()) {
> > if (TemplDecl == TemplDef) {
> > TRY_TO(TraverseImplicitClassInstantiations(D));
> > }
> > }
> > }
> >
> > Is this the correct approach ?
>
> This works, but it's sufficient to call isDefinition() on the templated
> decl. I've also just added isThisDeclarationADefinition() overloads to
> the template decls, so it should be even easier. :)
>
> John.
More information about the cfe-commits
mailing list