[cfe-dev] [analyzer] How to walk AST template instantiations

Ben Craig via cfe-dev cfe-dev at lists.llvm.org
Tue Nov 3 07:31:25 PST 2015


Thanks all.
What I ended up doing is switching to check::ASTDecl<TranslationUnitDecl> (as suggested by Anna Zaks), and then making the implementation of that function use a DataRecursiveASTVisitor.  That let me set shouldVisitTemplateInstantiations locally, instead of inflicting my choice on the rest of the checker world.  I did have to const_cast the TranslationUnitDecl, but other uses of the RecursiveASTVisitor seem to do that as well, so I'm not too concerned with the cast.

Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

-----Original Message-----
From: ganna at apple.com [mailto:ganna at apple.com] 
Sent: Tuesday, November 03, 2015 3:16 AM
To: Ben Craig
Cc: cfe-dev; Artem Dergachev
Subject: Re: [cfe-dev] [analyzer] How to walk AST template instantiations


> On Nov 3, 2015, at 12:22 AM, Artem Dergachev via cfe-dev <cfe-dev at lists.llvm.org> wrote:
> 
> Hello,
> 
> > What is the best way for analysis AST visitors to visit template 
> > instantiations?
> 
> As a quick workaround, you can subscribe on 
> check::EndOfTranslationUnit (which is not a path-sensitive callback,

Can check::ASTDecl<TranslationUnitDecl> be used instead? It’s a better fit for non-path sensitive checkers.

> even though it fires (once) after all path-sensitive callbacks if they are at all triggered) and then use any combinations of StmtVisitor's and DeclVisitor's, or even ASTMatchers, over the TranslationUnitDecl (the whole AST), for very fine-grained control over what stuff you do and do not visit.
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev





More information about the cfe-dev mailing list