]> granicus.if.org Git - clang/commit
Fix representation of compound literals for C++ objects with destructors.
authorJordan Rose <jordan_rose@apple.com>
Mon, 6 May 2013 16:48:12 +0000 (16:48 +0000)
committerJordan Rose <jordan_rose@apple.com>
Mon, 6 May 2013 16:48:12 +0000 (16:48 +0000)
commit2624b8157660902303bfce5551cfdd38272d01e5
treee189d230f3951bfe2b2dbb923459722a19890959
parentb8409215523e5478b8b0aa9cdcd10038cf7651fe
Fix representation of compound literals for C++ objects with destructors.

Previously, this compound literal expression (a GNU extension in C++):

  (AggregateWithDtor){1, 2}

resulted in this AST:

 `-CXXBindTemporaryExpr [...] 'struct Point' (CXXTemporary [...])
   `-CompoundLiteralExpr [...] 'struct AggregateWithDtor'
     `-CXXBindTemporaryExpr [...] 'struct AggregateWithDtor' (CXXTemporary [...])
       `-InitListExpr [...] 'struct AggregateWithDtor'
         |-IntegerLiteral [...] 'int' 1
         `-IntegerLiteral [...] 'int' 2

Note the two CXXBindTemporaryExprs. The InitListExpr is really part of the
CompoundLiteralExpr, not an object in its own right. By introducing a new
entity initialization kind in Sema specifically for compound literals, we
avoid the treatment of the inner InitListExpr as a temporary.

 `-CXXBindTemporaryExpr [...] 'struct Point' (CXXTemporary [...])
   `-CompoundLiteralExpr [...] 'struct AggregateWithDtor'
     `-InitListExpr [...] 'struct AggregateWithDtor'
       |-IntegerLiteral [...] 'int' 1
       `-IntegerLiteral [...] 'int' 2

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@181212 91177308-0d34-0410-b5e6-96231b3b80d8
include/clang/Sema/Initialization.h
lib/Sema/SemaExpr.cpp
lib/Sema/SemaInit.cpp
test/SemaCXX/compound-literal.cpp