[cfe-dev] How tor traverse an return expr?

Marcel Schaible via cfe-dev cfe-dev at lists.llvm.org
Thu Aug 3 07:49:53 PDT 2017


Hi everyone,

inside a FunctionDecl I have a return statement like e.g.

     return 1 + foo(p1,p2) * 2;

and I want to transform this into something like

/*1*/    temp = foo(p1,p2,p3);

/*2*/    return 1 + foo(p1,p2,p3) * 2;

How can I iterate over the return Expr to rewrite the call to foo?

The case /*2*/ is working fine with the use of a VisitCallExpr method.

The case /*1*/ is generated by using a rewriter and the rewriter does

not know about the /*2*/ transformation.

Thanks

Marcel






More information about the cfe-dev mailing list