[cfe-commits] [PATCH] Matchers for Types, QualTypes and TypeLocs
klimek at google.com
Wed Oct 17 00:56:39 PDT 2012
Comment at: lib/ASTMatchers/ASTMatchFinder.cpp:560
@@ +559,3 @@
+ // RecursiveASTVisitor by itself would only visit the TypeLocs, not the
+ // contained types.
Daniel Jasper wrote:
> Manuel Klimek wrote:
> > The question is: why do we want to traverse the Types here?
> We do not traverse the Types. We only match them. So basically, whenever you find a TypeLoc hierarchy in the AST, there is a corresponding Type hierarchy. The RecursiveASTVisitor does not visit both, as the TypeLoc is sort of a superset of the Type. However, when matching, we also want to match the contained types, if we happen to have a type-matcher, no?
> So, what we basically do is traverse the hierarchy once and try to match both Types and TypeLocs.
Yes, sorry, I meant "the question is: why do we want to match the Types here".
So, here's a proposal for the comment:
The RecursiveASTVisitor only visits types if they're not within TypeLocs. We still want to find those types via matchers, so we match them here. Note that the TypeLocs are structurally a shadow-hierarchy to the expressed type, so we visit all involved parts of a compound type when matching on each TypeLoc.
More information about the cfe-commits