[cfe-commits] r124310 - /cfe/trunk/lib/CodeGen/CGExpr.cpp
John McCall
rjmccall at apple.com
Wed Jan 26 11:21:14 PST 2011
Author: rjmccall
Date: Wed Jan 26 13:21:13 2011
New Revision: 124310
URL: http://llvm.org/viewvc/llvm-project?rev=124310&view=rev
Log:
Un-nest the meat of this function.
Modified:
cfe/trunk/lib/CodeGen/CGExpr.cpp
Modified: cfe/trunk/lib/CodeGen/CGExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExpr.cpp?rev=124310&r1=124309&r2=124310&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExpr.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExpr.cpp Wed Jan 26 13:21:13 2011
@@ -1682,67 +1682,66 @@
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);
- }
-
- llvm::BasicBlock *LHSBlock = createBasicBlock("cond.true");
- llvm::BasicBlock *RHSBlock = createBasicBlock("cond.false");
- llvm::BasicBlock *ContBlock = createBasicBlock("cond.end");
-
- 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);
- }
-
- // 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");
-
- 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());
+ if (!E->isGLValue()) {
+ // ?: here should be an aggregate.
+ assert((hasAggregateLLVMType(E->getType()) &&
+ !E->getType()->isAnyComplexType()) &&
+ "Unexpected conditional operator!");
+ return EmitAggExprToLValue(E);
}
-
- // ?: here should be an aggregate.
- assert((hasAggregateLLVMType(E->getType()) &&
- !E->getType()->isAnyComplexType()) &&
- "Unexpected conditional operator!");
- return EmitAggExprToLValue(E);
+ 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);
+
+ 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);
+
+ if (!LHS.isSimple())
+ return EmitUnsupportedLValue(E, "conditional operator");
+
+ 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());
}
/// EmitCastLValue - Casts are never lvalues unless that cast is a dynamic_cast.
More information about the cfe-commits
mailing list