[cfe-dev] Remove implicitly generated AST nodes by Sema

Pan, Wei wei.pan at intel.com
Tue Jun 4 11:56:07 PDT 2013


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

------------------------------------------------------------------

struct Y { };
struct X { X(); X(Y&); };
void foo(X);

void bar(Y &y) {
  foo(y);     // (1)
  foo(X(y));  // (2)
}

|-CallExpr 0x2a6c790 <line:8:3, col:8> 'void'
| |-ImplicitCastExpr 0x2a6c778 <col:3> 'void (*)(struct X)' <FunctionToPointerDecay>
| | `-DeclRefExpr 0x2a6c728 <col:3> 'void (struct X)' lvalue Function 0x2a6c2c0 'foo' 'void (struct X)'
| `-CXXConstructExpr 0x2a6c9f8 <col:7> 'struct X' 'void (const struct X &) throw()' elidable
|   `-MaterializeTemporaryExpr 0x2a6c988 <col:7> 'const struct X' lvalue
|     `-ImplicitCastExpr 0x2a6c970 <col:7> 'const struct X' <NoOp>
|       `-ImplicitCastExpr 0x2a6c800 <col:7> 'struct X' <ConstructorConversion>
|         `-CXXConstructExpr 0x2a6c7c8 <col:7> 'struct X' 'void (struct Y &)'
|           `-DeclRefExpr 0x2a6c500 <col:7> 'struct Y' lvalue ParmVar 0x2a6c380 'y' 'struct Y &'
`-CallExpr 0x2a6cb60 <line:9:3, col:11> 'void'
  |-ImplicitCastExpr 0x2a6cb48 <col:3> 'void (*)(struct X)' <FunctionToPointerDecay>
  | `-DeclRefExpr 0x2a6cb20 <col:3> 'void (struct X)' lvalue Function 0x2a6c2c0 'foo' 'void (struct X)'
   `-CXXConstructExpr 0x2a6cbc8 <col:7, col:10> 'struct X' 'void (const struct X &) throw()' elidable
     `-MaterializeTemporaryExpr 0x2a6cbb0 <col:7, col:10> 'const struct X' lvalue
       `-ImplicitCastExpr 0x2a6cb98 <col:7, col:10> 'const struct X' <NoOp>
         `-CXXFunctionalCastExpr 0x2a6caf8 <col:7, col:10> 'struct X' functional cast to struct X <ConstructorConversion>
           `-CXXConstructExpr 0x2a6cac0 <col:7, col:10> 'struct X' 'void (struct Y &)'
             `-DeclRefExpr 0x2a6ca98 <col:9> 'struct Y' lvalue ParmVar 0x2a6c380 'y' 'struct Y &'




More information about the cfe-dev mailing list