diff options
author | John McCall <rjmccall@apple.com> | 2010-12-06 06:10:02 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-12-06 06:10:02 +0000 |
commit | cd940a1e13e588a43973cd7ae33b5c33a3062739 (patch) | |
tree | 0e252caddabd8025cb89eae60011e4a67fb65a97 /lib/CodeGen/CGExpr.cpp | |
parent | 01b2e4e3e2fbd60e62539f7e8e8b99575fa8a5b0 (diff) |
__block variables require us to evaluate the RHS of an assignment before
the LHS, or else the pointer might be invalid. This is kindof dumb, but
go ahead and make sure we're doing that for l-value scalar assignment,
which fixes a miscompile of obj-c++.dg/block-seq.mm.
Leave a FIXME for how to solve this problem for agg __blocks.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120992 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExpr.cpp')
-rw-r--r-- | lib/CodeGen/CGExpr.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 011233c58f..6cc573c0cf 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1951,10 +1951,10 @@ LValue CodeGenFunction::EmitBinaryOperatorLValue(const BinaryOperator *E) { assert(E->getOpcode() == BO_Assign && "unexpected binary l-value"); if (!hasAggregateLLVMType(E->getType())) { - // Emit the LHS as an l-value. + // __block variables need the RHS evaluated first. + RValue RV = EmitAnyExpr(E->getRHS()); LValue LV = EmitLValue(E->getLHS()); - // Store the value through the l-value. - EmitStoreThroughLValue(EmitAnyExpr(E->getRHS()), LV, E->getType()); + EmitStoreThroughLValue(RV, LV, E->getType()); return LV; } |