[cfe-dev] How to reconstruct the stack of template instantiations.

Craig Silverstein csilvers at google.com
Mon Aug 22 10:55:54 PDT 2011


} Are there simpler ways to achieve the same end result?

What I do in include-what-you-use
(http://code.google.com/p/include-what-you-use) is to just keep track
of the entire call-stack as I'm traversing the AST.  The relevant
parts are the ASTNode class (in iwyu_ast_util.h), and the ASTNode
updaters in TraverseDecl, TraverseStmt, and TraverseType.

Using this, whenever you see a template node, you can go up the
ASTNode chain to see all the parents in the AST, which includes the
parents that caused the various template instantiations.  Does that
work for you?

craig



More information about the cfe-dev mailing list