Remove implicitly generated AST nodes by Sema

Hi all,

I am wondering if it is possible to remove all the implicitly generated AST nodes.

For example (below), the only argument to call (1) is a "DeclRefExpr" to y, and the only
argument to call (2) is a "CXXContructExpr", if ignoring nodes created by the initialization
sequence for the call.

Basically, I want to get the "syntactic form" Expr from an expression with some semantic
analysis. Is there an existing way to do so? Or what would be a proper way to implement this?

Thanks!

Wei

Expr::IgnoreImplicit() lets you easily look through implicit expressions.

-Eli

Seemly this function can only remove implicit casts. There are some AST nodes, like CXXConstructExpr in the example, which will stick there.

http://clang.llvm.org/doxygen/Stmt_8cpp_source.html#l00099

Wei

CastExpr::getSubExprAsWritten knows how to look through the constructor
conversions in particular... it's possible that we're missing methods what
you want, though. A lot of code in clang avoids that sort of thing by just
using a StmtVisitor and just ignoring expressions it doesn't want to handle.

-Eli

For the following example, the argument in the call “foo(x)” does not have an implicit cast on top of the CXXConstructExpr. Is it generally right to generate one for this call? If yes, then CastExpr::getSubExprAsWritten would work here.

void foo(Y y);

void bar(X x) {

foo(x);
}

Thanks!

Wei

There are three CXXConstructExprs here: one is the ConstructorConversion,
and the other two are copy constructors. Off the top of my head, I'm not
sure there's a convenient way to check whether a CXXConstructExpr is an
implicit copy constructor call.

-Eli