Use PushConditionalTempDestruction/PopConditionalTempDestruction for the ternary operator.

llvm-svn: 72842
This commit is contained in:
Anders Carlsson 2009-06-04 03:00:32 +00:00
parent f47a3de83c
commit 43c52cdc29
2 changed files with 9 additions and 1 deletions

View File

@ -263,17 +263,21 @@ void AggExprEmitter::VisitConditionalOperator(const ConditionalOperator *E) {
llvm::Value *Cond = CGF.EvaluateExprAsBool(E->getCond());
Builder.CreateCondBr(Cond, LHSBlock, RHSBlock);
CGF.PushConditionalTempDestruction();
CGF.EmitBlock(LHSBlock);
// Handle the GNU extension for missing LHS.
assert(E->getLHS() && "Must have LHS for aggregate value");
Visit(E->getLHS());
CGF.PopConditionalTempDestruction();
CGF.EmitBranch(ContBlock);
CGF.PushConditionalTempDestruction();
CGF.EmitBlock(RHSBlock);
Visit(E->getRHS());
CGF.PopConditionalTempDestruction();
CGF.EmitBranch(ContBlock);
CGF.EmitBlock(ContBlock);

View File

@ -1452,7 +1452,8 @@ VisitConditionalOperator(const ConditionalOperator *E) {
CGF.getContext().BoolTy);
Builder.CreateCondBr(CondBoolVal, LHSBlock, RHSBlock);
}
CGF.PushConditionalTempDestruction();
CGF.EmitBlock(LHSBlock);
// Handle the GNU extension for missing LHS.
@ -1462,12 +1463,15 @@ VisitConditionalOperator(const ConditionalOperator *E) {
else // Perform promotions, to handle cases like "short ?: int"
LHS = EmitScalarConversion(CondVal, E->getCond()->getType(), E->getType());
CGF.PopConditionalTempDestruction();
LHSBlock = Builder.GetInsertBlock();
CGF.EmitBranch(ContBlock);
CGF.PushConditionalTempDestruction();
CGF.EmitBlock(RHSBlock);
Value *RHS = Visit(E->getRHS());
CGF.PopConditionalTempDestruction();
RHSBlock = Builder.GetInsertBlock();
CGF.EmitBranch(ContBlock);