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 | 4e43dec4df9d7dd8e07b47bb15967f1b733a9bc6 (patch) | |
| tree | 9086f9d869601badde80510b7bbd34accaad5756 /lib/CodeGen/CGExpr.cpp | |
| parent | c063cb1e1a2e4b76f27762fcf56b4ba2ede8f0a9 (diff) | |
| download | clang-4e43dec4df9d7dd8e07b47bb15967f1b733a9bc6.tar.gz clang-4e43dec4df9d7dd8e07b47bb15967f1b733a9bc6.tar.bz2 clang-4e43dec4df9d7dd8e07b47bb15967f1b733a9bc6.tar.xz | |
Fix handling of pointers-to-members and comma expressions when
lifetime-extending temporaries in reference bindings.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@183089 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
| -rw-r--r-- | lib/CodeGen/CGExpr.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 8ba5a1ce52..28eae50832 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/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. |
