aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2013-05-06 16:48:12 +0000
committerJordan Rose <jordan_rose@apple.com>2013-05-06 16:48:12 +0000
commit2624b8157660902303bfce5551cfdd38272d01e5 (patch)
treee189d230f3951bfe2b2dbb923459722a19890959 /lib/Sema/SemaExpr.cpp
parentb8409215523e5478b8b0aa9cdcd10038cf7651fe (diff)
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
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 18c1d8fb32..0c1065813e 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -4509,7 +4509,7 @@ Sema::BuildCompoundLiteralExpr(SourceLocation LParenLoc, TypeSourceInfo *TInfo,
return ExprError();
InitializedEntity Entity
- = InitializedEntity::InitializeTemporary(literalType);
+ = InitializedEntity::InitializeCompoundLiteralInit(TInfo);
InitializationKind Kind
= InitializationKind::CreateCStyleCast(LParenLoc,
SourceRange(LParenLoc, RParenLoc),