Clang Plugin - RecursiveASTVisitor : Find instantiations of a type (RecordDecl)


In the method TraverseFieldDecl of a RecursiveASTVisitor, would it be possible to find all the instantiations of a specific type (RecordDecl) ?

In this particular case, a class X (retrieved via getParent() method) contains a field (parsed by the TraverseFieldDecl) and I would like to check the parameters passed to that class X when instantiated.

Thanks for your help,

I am not an expert on this subject, but I believe - AST Matchers should help
in this. Please check the docs:

Specifically, you are looking for 'Stmt'. It should help you find the nodes
at the statement level, and you should be able to craft a DeclarationMatcher
that filters the statements based on exact criteria you specified in your

If you take that direction, then this post may also help you overcome the
'compilation database' requirement of libTooling:

Hope this helps.

Thank you,
GK (Gopalakrishna)