diff options
author | John McCall <rjmccall@apple.com> | 2010-11-17 00:07:33 +0000 |
---|---|---|
committer | John McCall <rjmccall@apple.com> | 2010-11-17 00:07:33 +0000 |
commit | 74fb0edb44b7ed52af9b8053032ccaab29b5c0cc (patch) | |
tree | 0dd346214296566dc95d5a27683995f2f060c8c0 /lib/CodeGen/CGExprAgg.cpp | |
parent | 34c26300b384286c544e0b9fd45e7a3648ac79e3 (diff) |
Reset the lifetime-managed flag between emission of the agg conditional
branches. Fixes PR8623.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119408 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CGExprAgg.cpp')
-rw-r--r-- | lib/CodeGen/CGExprAgg.cpp | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index 00cfb21447..308520aadd 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -394,8 +394,8 @@ void AggExprEmitter::VisitConditionalOperator(const ConditionalOperator *E) { CGF.BeginConditionalBranch(); CGF.EmitBlock(LHSBlock); - // Handle the GNU extension for missing LHS. - assert(E->getLHS() && "Must have LHS for aggregate value"); + // Save whether the destination's lifetime is externally managed. + bool DestLifetimeManaged = Dest.isLifetimeExternallyManaged(); Visit(E->getLHS()); CGF.EndConditionalBranch(); @@ -404,6 +404,12 @@ void AggExprEmitter::VisitConditionalOperator(const ConditionalOperator *E) { CGF.BeginConditionalBranch(); CGF.EmitBlock(RHSBlock); + // If the result of an agg expression is unused, then the emission + // of the LHS might need to create a destination slot. That's fine + // with us, and we can safely emit the RHS into the same slot, but + // we shouldn't claim that its lifetime is externally managed. + Dest.setLifetimeExternallyManaged(DestLifetimeManaged); + Visit(E->getRHS()); CGF.EndConditionalBranch(); CGF.EmitBranch(ContBlock); |