[cfe-dev] AST for C++11 brace initialization includes CompoundLiteralExpr?

Jordan Rose jordan_rose at apple.com
Fri May 3 11:16:41 PDT 2013

How about this one? Is the inner init list really creating a Point which is then copied by the CompoundLiteralExpr?

struct Point {
	int x, y;

void test() {

`-FunctionDecl 0x7f9558860720 <line:6:1, line:8:1> test 'void (void)'
  `-CompoundStmt 0x7f9558860990 <line:6:13, line:8:1>
    `-ExprWithCleanups 0x7f9558860978 <line:7:2, col:15> 'struct Point'
      `-ParenExpr 0x7f9558860958 <col:2, col:15> 'struct Point'
        `-CXXBindTemporaryExpr 0x7f9558860938 <col:3, col:14> 'struct Point' (CXXTemporary 0x7f9558860930)
          `-CompoundLiteralExpr 0x7f9558860908 <col:3, col:14> 'struct Point'
            `-CXXBindTemporaryExpr 0x7f95588608e8 <col:10, col:14> 'struct Point' (CXXTemporary 0x7f95588608e0)
              `-InitListExpr 0x7f9558860860 <col:10, col:14> 'struct Point'
                |-IntegerLiteral 0x7f95588607d0 <col:11> 'int' 1
                `-IntegerLiteral 0x7f95588607f0 <col:13> 'int' 2

(This is the same AST whether in C++03 or C++11.)

For comparison:

struct Point {
	Point(int x, int y);

void test() {

`-FunctionDecl 0x7ffb3c060460 <line:6:1, line:8:1> test 'void (void)'
  `-CompoundStmt 0x7ffb3c0608b0 <line:6:13, line:8:1>
    `-ExprWithCleanups 0x7ffb3c060898 <line:7:2, col:15> 'struct Point'
      `-ParenExpr 0x7ffb3c060878 <col:2, col:15> 'struct Point'
        `-CXXBindTemporaryExpr 0x7ffb3c060858 <col:3, <invalid sloc>> 'struct Point' (CXXTemporary 0x7ffb3c060850)
          `-CompoundLiteralExpr 0x7ffb3c060828 <col:3, <invalid sloc>> 'struct Point'
            `-CXXBindTemporaryExpr 0x7ffb3c060808 <col:3, <invalid sloc>> 'struct Point' (CXXTemporary 0x7ffb3c060800)
              `-CXXTemporaryObjectExpr 0x7ffb3c060780 <col:3, <invalid sloc>> 'struct Point' 'void (int, int)'
                |-IntegerLiteral 0x7ffb3c060510 <col:11> 'int' 1
                `-IntegerLiteral 0x7ffb3c060530 <col:13> 'int' 2

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20130503/1da2cc56/attachment.html>

More information about the cfe-dev mailing list