[cfe-dev] Question about RecursiveASTVisitor behavior on lvalue UnaryOperator

Jiaqi Tan jiaqi.tan at gmail.com
Fri Jul 10 15:19:48 PDT 2015


Hi,

I have the following fragment of C code:

*--dst = *--src;

When I try to call my RecursiveASTVisitor on the LHS Expr (i.e. the *--dst
part), the default TraverseStmt behavior seems to skip over the prefix
decrement --.

When I do a Stmt->dump() on the whole LHS Expr, I get:
UnaryOperator 0x7ff4e38975d8 'char' lvalue prefix '*'
`-UnaryOperator 0x7ff4e38975b8 'char *' prefix '--'
  `-DeclRefExpr 0x7ff4e3897590 'char *' lvalue Var 0x7ff4e3883920 'dst'
'char *'

But when I actually call TraverseStmt() on the top-level LHS Expr above,
after processing the first UnaryOperator (the one for the derefence, *),
the next call to TraverseStmt() immediately returns only the DeclRefExpr.

My TraverseStmt(Stmt *S) contains only:
  bool TraverseStmt (Stmt *S) {
   return this->RecursiveASTVisitor::TraverseStmt(S);
  }

Does anybody know what TraverseStmt's default behavior in
RecursiveASTVisitor is doing, and why it seems to jumping over the prefix
-- node in the AST during the AST traversal?

Thanks!
Jiaqi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20150710/9ae100b1/attachment.html>


More information about the cfe-dev mailing list