[cfe-dev] Collect template instantiations from clang AST

Stephan Bergmann via cfe-dev cfe-dev at lists.llvm.org
Wed Apr 12 00:45:22 PDT 2017


On 04/11/2017 12:37 AM, Яковлев Влад via cfe-dev wrote:
> I am trying to collect all template instantiations via traversing AST with RecursiveASTVisitor. I thought I would be able to do it with VisitFunctionDecl from class RecursiveASTVisitor and getTemplateInstantiationPattern from class FunctionDecl. However, as mentioned in the comment to this method, it just returns the function declaration, from wich it could be instantiated. I discovered that this method returns the first acceptable pattern from the context of instantiation. Is there any way to get a real pattern out of a function template instantiation?

There's RecursiveASTVisitor::shouldVisitTemplateInstantiations() 
(defaulting to false) which you can "override" in your derivation.



More information about the cfe-dev mailing list