diff options
| author | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-06-03 00:17:11 +0000 |
|---|---|---|
| committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2013-06-03 00:17:11 +0000 |
| commit | f3fabd2cb5bdeb6396e0bad7023750eca2f67674 (patch) | |
| tree | 67cf613bd85bda224b51a5e3802b690821ed377e /clang/lib/CodeGen/CGExpr.cpp | |
| parent | 0bbe1b210e79e7b63d7b5c7c6cdf24e13b5493a1 (diff) | |
| download | bcm5719-llvm-f3fabd2cb5bdeb6396e0bad7023750eca2f67674.tar.gz bcm5719-llvm-f3fabd2cb5bdeb6396e0bad7023750eca2f67674.zip | |
Fix handling of pointers-to-members and comma expressions when
lifetime-extending temporaries in reference bindings.
llvm-svn: 183089
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index 8ba5a1ce522..28eae50832a 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -295,8 +295,13 @@ EmitExprForReferenceBinding(CodeGenFunction &CGF, const Expr *E, return ReferenceTemporary; } + SmallVector<const Expr *, 2> CommaLHSs; SmallVector<SubobjectAdjustment, 2> Adjustments; - E = E->skipRValueSubobjectAdjustments(Adjustments); + E = E->skipRValueSubobjectAdjustments(CommaLHSs, Adjustments); + + for (unsigned I = 0, N = CommaLHSs.size(); I != N; ++I) + CGF.EmitIgnoredExpr(CommaLHSs[I]); + if (const OpaqueValueExpr *opaque = dyn_cast<OpaqueValueExpr>(E)) if (opaque->getType()->isRecordType()) return CGF.EmitOpaqueValueLValue(opaque).getAddress(); @@ -332,6 +337,10 @@ EmitExprForReferenceBinding(CodeGenFunction &CGF, const Expr *E, RValue RV = CGF.EmitAnyExpr(E, AggSlot); + // FIXME: This is wrong. We need to register the destructor for the temporary + // now, *before* we perform the adjustments, because in the case of a + // pointer-to-member adjustment, the adjustment might throw. + // Check if need to perform derived-to-base casts and/or field accesses, to // get from the temporary object we created (and, potentially, for which we // extended the lifetime) to the subobject we're binding the reference to. |

