TraverseExplicitCastExpr?

Hi,

I’m writing a clang libtool using RecursiveASTVisitor, and I’ve noticed that I can define Traverse* for some types, but not others. For instance, I can define TraverseArraySubscriptExpr() and TraverseMemberExpr(), but not TraverseExplicitCastExpr(). So I can write

bool MyVisitor::TraverseExplicitCastExpr(ExplicitCastExpr *ECE) {
// do some stuff
return RecursiveASTVisitor::TraverseExplicitCastExpr(ECE);
}

but then the compiler complains that there is no TraverseExplicitCastExpr in the base class RecursiveASTVisitor. But if I do the same for an ArraySubscriptExpr, it compiles just fine.

Any insight into this matter would be much appreciated.

Thanks,

Scott Constable

I figured out the problem myself. Traverse* only hits the base class of each node (e.g. Decl, Stmt, or Type), and the dynamic class of each node. Since ExplicitCastExpr is abstract, TraverseExplicitCastExpr is not valid. Instead I needed to use VisitExplicitCastExpr.