From 4e43dec4df9d7dd8e07b47bb15967f1b733a9bc6 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Mon, 3 Jun 2013 00:17:11 +0000 Subject: 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 --- lib/CodeGen/CGExpr.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'lib/CodeGen/CGExpr.cpp') 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 CommaLHSs; SmallVector 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(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. -- cgit v1.2.3