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/AST/Expr.cpp b/lib/AST/Expr.cpp
index d0d14f2..38bcc9b 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -603,11 +603,7 @@
return LV_Valid;
case ChooseExprClass:
// __builtin_choose_expr is an lvalue if the selected operand is.
- if (cast<ChooseExpr>(this)->isConditionTrue(Ctx))
- return cast<ChooseExpr>(this)->getLHS()->isLvalue(Ctx);
- else
- return cast<ChooseExpr>(this)->getRHS()->isLvalue(Ctx);
-
+ return cast<ChooseExpr>(this)->getChosenSubExpr(Ctx)->isLvalue(Ctx);
case ExtVectorElementExprClass:
if (cast<ExtVectorElementExpr>(this)->containsDuplicateElements())
return LV_DuplicateVectorComponents;
@@ -1110,9 +1106,7 @@
case Expr::CXXDefaultArgExprClass:
return CheckICE(cast<CXXDefaultArgExpr>(E)->getExpr(), Ctx);
case Expr::ChooseExprClass: {
- const ChooseExpr *CE = cast<ChooseExpr>(E);
- Expr *SubExpr = CE->isConditionTrue(Ctx) ? CE->getLHS() : CE->getRHS();
- return CheckICE(SubExpr, Ctx);
+ return CheckICE(cast<ChooseExpr>(E)->getChosenSubExpr(Ctx), Ctx);
}
}
}