Missing info in AST for CXXConstructExpr

Abramo Bagnara abramo.bagnara at bugseng.com
Sat Jan 24 03:40:14 PST 2015


For the following source:

#include <initializer_list>
typedef std::initializer_list<int> T;

void f(T);

template <typename U>
void g(U);

int main() {
  f(T{0});
  g(T{0});
}

I get this AST (initial part is omitted as it is not relevant):

`-FunctionDecl 0x7960cc0 <line:9:1, line:12:1> line:9:5 main 'int (void)'
  `-CompoundStmt 0x7962d50 <col:12, line:12:1>
    |-CallExpr 0x7962180 <line:10:3, col:9> 'void'
    | |-ImplicitCastExpr 0x7962168 <col:3> 'void (*)(T)'
<FunctionToPointerDecay>
    | | `-DeclRefExpr 0x79620e0 <col:3> 'void (T)' lvalue Function
0x7960940 'f' 'void (T)'
    | `-CXXConstructExpr 0x79627a8 <col:6, col:8> 'T':'class
std::initializer_list<int>' 'void (class std::initializer_list<int> &&)
noexcept' elidable
    |   `-MaterializeTemporaryExpr 0x7962550 <col:6, col:8> 'class
std::initializer_list<int>' xvalue
    |     `-CXXStdInitializerListExpr 0x7961fa8 <col:6, col:8>
'T':'class std::initializer_list<int>'
    |       `-MaterializeTemporaryExpr 0x7961f90 <col:6, col:8> 'const
int [1]' xvalue
    |         `-InitListExpr 0x7961f48 <col:6, col:8> 'const int [1]'
    |           `-IntegerLiteral 0x7960e20 <col:7> 'int' 0
    `-CallExpr 0x7962cd0 <line:11:3, col:9> 'void'
      |-ImplicitCastExpr 0x7962cb8 <col:3> 'void (*)(class
std::initializer_list<int>)' <FunctionToPointerDecay>
      | `-DeclRefExpr 0x7962c60 <col:3> 'void (class
std::initializer_list<int>)' lvalue Function 0x7962b60 'g' 'void (class
std::initializer_list<int>)' (FunctionTemplate 0x7960c20 'g')
      `-CXXConstructExpr 0x7962d18 <col:6, col:8> 'class
std::initializer_list<int>':'class std::initializer_list<int>' 'void
(class std::initializer_list<int> &&) noexcept' elidable
        `-MaterializeTemporaryExpr 0x7962d00 <col:6, col:8> 'class
std::initializer_list<int>' xvalue
          `-CXXStdInitializerListExpr 0x7962910 <col:6, col:8>
'T':'class std::initializer_list<int>'
            `-MaterializeTemporaryExpr 0x79628f8 <col:6, col:8> 'const
int [1]' xvalue
              `-InitListExpr 0x79628b0 <col:6, col:8> 'const int [1]'
                `-IntegerLiteral 0x7962848 <col:7> 'int' 0

Looking at AST (and clang sources) I can note two things:

1) no nodes contains the written TypeLoc for T in function calls
2) the source range for CXXConstructExpr is wrong
3) the type is not printed by StmtPrinter.

Once confirmed that, what is the node that should contain such type info
(if any)?

-- 
Abramo Bagnara

BUGSENG srl - http://bugseng.com
mailto:abramo.bagnara at bugseng.com



More information about the cfe-commits mailing list