Minor cleanup for choose expressions: add a helper that returns the 
chosen sub-expression, rather than just evaluating the condition.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66018 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index d54c695..3ab8568 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -178,11 +178,7 @@
   case Expr::CompoundLiteralExprClass:
     return EmitCompoundLiteralLValue(cast<CompoundLiteralExpr>(E));
   case Expr::ChooseExprClass:
-    // __builtin_choose_expr is the lvalue of the selected operand.
-    if (cast<ChooseExpr>(E)->isConditionTrue(getContext()))
-      return EmitLValue(cast<ChooseExpr>(E)->getLHS());
-    else
-      return EmitLValue(cast<ChooseExpr>(E)->getRHS());
+    return EmitLValue(cast<ChooseExpr>(E)->getChosenSubExpr(getContext()));
   }
 }
 
diff --git a/lib/CodeGen/CGExprComplex.cpp b/lib/CodeGen/CGExprComplex.cpp
index c676b57..e970ba2 100644
--- a/lib/CodeGen/CGExprComplex.cpp
+++ b/lib/CodeGen/CGExprComplex.cpp
@@ -509,8 +509,7 @@
 }
 
 ComplexPairTy ComplexExprEmitter::VisitChooseExpr(ChooseExpr *E) {
-  // Emit the LHS or RHS as appropriate.
-  return Visit(E->isConditionTrue(CGF.getContext()) ? E->getLHS() :E->getRHS());
+  return Visit(E->getChosenSubExpr(CGF.getContext()));
 }
 
 ComplexPairTy ComplexExprEmitter::VisitInitListExpr(InitListExpr *E) {
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 38cc3ee..9951d87 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -1307,9 +1307,7 @@
 }
 
 Value *ScalarExprEmitter::VisitChooseExpr(ChooseExpr *E) {
-  // Emit the LHS or RHS as appropriate.
-  return
-    Visit(E->isConditionTrue(CGF.getContext()) ? E->getLHS() : E->getRHS());
+  return Visit(E->getChosenSubExpr(CGF.getContext()));
 }
 
 Value *ScalarExprEmitter::VisitVAArgExpr(VAArgExpr *VE) {