From: John McCall Date: Wed, 26 Jan 2011 19:21:13 +0000 (+0000) Subject: Un-nest the meat of this function. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f99a3915389109a716caafacb41fd9c4a3b8f432;p=clang Un-nest the meat of this function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124310 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp index 35c2a2992b..afc1e0709e 100644 --- a/lib/CodeGen/CGExpr.cpp +++ b/lib/CodeGen/CGExpr.cpp @@ -1682,67 +1682,66 @@ LValue CodeGenFunction::EmitCompoundLiteralLValue(const CompoundLiteralExpr *E){ LValue CodeGenFunction::EmitConditionalOperatorLValue(const ConditionalOperator *E) { - if (E->isGLValue()) { - if (int Cond = ConstantFoldsToSimpleInteger(E->getCond())) { - Expr *Live = Cond == 1 ? E->getLHS() : E->getRHS(); - if (Live) - return EmitLValue(Live); - } + if (!E->isGLValue()) { + // ?: here should be an aggregate. + assert((hasAggregateLLVMType(E->getType()) && + !E->getType()->isAnyComplexType()) && + "Unexpected conditional operator!"); + return EmitAggExprToLValue(E); + } - llvm::BasicBlock *LHSBlock = createBasicBlock("cond.true"); - llvm::BasicBlock *RHSBlock = createBasicBlock("cond.false"); - llvm::BasicBlock *ContBlock = createBasicBlock("cond.end"); + if (int Cond = ConstantFoldsToSimpleInteger(E->getCond())) { + Expr *Live = Cond == 1 ? E->getLHS() : E->getRHS(); + if (Live) + return EmitLValue(Live); + } + + llvm::BasicBlock *LHSBlock = createBasicBlock("cond.true"); + llvm::BasicBlock *RHSBlock = createBasicBlock("cond.false"); + llvm::BasicBlock *ContBlock = createBasicBlock("cond.end"); - ConditionalEvaluation eval(*this); + ConditionalEvaluation eval(*this); - if (E->getLHS()) - EmitBranchOnBoolExpr(E->getCond(), LHSBlock, RHSBlock); - else { - Expr *save = E->getSAVE(); - assert(save && "VisitConditionalOperator - save is null"); - // Intentianlly not doing direct assignment to ConditionalSaveExprs[save] - LValue SaveVal = EmitLValue(save); - ConditionalSaveLValueExprs[save] = SaveVal; - EmitBranchOnBoolExpr(E->getCond(), LHSBlock, RHSBlock); - } + if (E->getLHS()) + EmitBranchOnBoolExpr(E->getCond(), LHSBlock, RHSBlock); + else { + Expr *save = E->getSAVE(); + assert(save && "VisitConditionalOperator - save is null"); + // Intentianlly not doing direct assignment to ConditionalSaveExprs[save] + LValue SaveVal = EmitLValue(save); + ConditionalSaveLValueExprs[save] = SaveVal; + EmitBranchOnBoolExpr(E->getCond(), LHSBlock, RHSBlock); + } - // Any temporaries created here are conditional. - EmitBlock(LHSBlock); - eval.begin(*this); - LValue LHS = EmitLValue(E->getTrueExpr()); - eval.end(*this); + // Any temporaries created here are conditional. + EmitBlock(LHSBlock); + eval.begin(*this); + LValue LHS = EmitLValue(E->getTrueExpr()); + eval.end(*this); - if (!LHS.isSimple()) - return EmitUnsupportedLValue(E, "conditional operator"); + if (!LHS.isSimple()) + return EmitUnsupportedLValue(E, "conditional operator"); - LHSBlock = Builder.GetInsertBlock(); - Builder.CreateBr(ContBlock); + LHSBlock = Builder.GetInsertBlock(); + Builder.CreateBr(ContBlock); - // Any temporaries created here are conditional. - EmitBlock(RHSBlock); - eval.begin(*this); - LValue RHS = EmitLValue(E->getRHS()); - eval.end(*this); - if (!RHS.isSimple()) - return EmitUnsupportedLValue(E, "conditional operator"); - RHSBlock = Builder.GetInsertBlock(); - - EmitBlock(ContBlock); - - llvm::PHINode *phi = Builder.CreatePHI(LHS.getAddress()->getType(), - "cond-lvalue"); - phi->reserveOperandSpace(2); - phi->addIncoming(LHS.getAddress(), LHSBlock); - phi->addIncoming(RHS.getAddress(), RHSBlock); - return MakeAddrLValue(phi, E->getType()); - } - - // ?: here should be an aggregate. - assert((hasAggregateLLVMType(E->getType()) && - !E->getType()->isAnyComplexType()) && - "Unexpected conditional operator!"); - - return EmitAggExprToLValue(E); + // Any temporaries created here are conditional. + EmitBlock(RHSBlock); + eval.begin(*this); + LValue RHS = EmitLValue(E->getRHS()); + eval.end(*this); + if (!RHS.isSimple()) + return EmitUnsupportedLValue(E, "conditional operator"); + RHSBlock = Builder.GetInsertBlock(); + + EmitBlock(ContBlock); + + llvm::PHINode *phi = Builder.CreatePHI(LHS.getAddress()->getType(), + "cond-lvalue"); + phi->reserveOperandSpace(2); + phi->addIncoming(LHS.getAddress(), LHSBlock); + phi->addIncoming(RHS.getAddress(), RHSBlock); + return MakeAddrLValue(phi, E->getType()); } /// EmitCastLValue - Casts are never lvalues unless that cast is a dynamic_cast.