diff options
| author | Douglas Gregor <dgregor@apple.com> | 2011-06-17 04:59:12 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2011-06-17 04:59:12 +0000 |
| commit | 9b71f0cfac3c4979781fae29e7fb0b8757714f60 (patch) | |
| tree | cbf3e447b1c8e2573ca185e896c27a84915fecec /clang/lib/CodeGen/CGExprAgg.cpp | |
| parent | 3982029f60761b30e0a3c222e5b9168e67b7c51c (diff) | |
| download | bcm5719-llvm-9b71f0cfac3c4979781fae29e7fb0b8757714f60.tar.gz bcm5719-llvm-9b71f0cfac3c4979781fae29e7fb0b8757714f60.zip | |
Implement proper support for generating code for compound literals in
C++, which means:
- binding the temporary as needed in Sema, so that we generate the
appropriate call to the destructor, and
- emitting the compound literal into the appropriate location for
the aggregate, rather than trying to emit it as a temporary and
memcpy() it.
Fixes PR10138 / <rdar://problem/9615901>.
llvm-svn: 133235
Diffstat (limited to 'clang/lib/CodeGen/CGExprAgg.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExprAgg.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp index c1ead814b9a..694316983e8 100644 --- a/clang/lib/CodeGen/CGExprAgg.cpp +++ b/clang/lib/CodeGen/CGExprAgg.cpp @@ -91,9 +91,7 @@ public: void VisitMemberExpr(MemberExpr *ME) { EmitAggLoadOfLValue(ME); } void VisitUnaryDeref(UnaryOperator *E) { EmitAggLoadOfLValue(E); } void VisitStringLiteral(StringLiteral *E) { EmitAggLoadOfLValue(E); } - void VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { - EmitAggLoadOfLValue(E); - } + void VisitCompoundLiteralExpr(CompoundLiteralExpr *E); void VisitArraySubscriptExpr(ArraySubscriptExpr *E) { EmitAggLoadOfLValue(E); } @@ -247,6 +245,13 @@ void AggExprEmitter::VisitOpaqueValueExpr(OpaqueValueExpr *e) { EmitFinalDestCopy(e, CGF.getOpaqueLValueMapping(e)); } +void +AggExprEmitter::VisitCompoundLiteralExpr(CompoundLiteralExpr *E) { + AggValueSlot Slot = EnsureSlot(E->getType()); + CGF.EmitAggExpr(E->getInitializer(), Slot); +} + + void AggExprEmitter::VisitCastExpr(CastExpr *E) { switch (E->getCastKind()) { case CK_Dynamic: { |

