diff options
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/AST/Expr.cpp | 10 | ||||
| -rw-r--r-- | clang/lib/AST/ExprConstant.cpp | 12 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGExpr.cpp | 6 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGExprComplex.cpp | 3 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGExprScalar.cpp | 4 |
5 files changed, 8 insertions, 27 deletions
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp index d0d14f2b7af..38bcc9bf315 100644 --- a/clang/lib/AST/Expr.cpp +++ b/clang/lib/AST/Expr.cpp @@ -603,11 +603,7 @@ Expr::isLvalueResult Expr::isLvalue(ASTContext &Ctx) const { 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 @@ static ICEDiag CheckICE(const Expr* E, ASTContext &Ctx) { 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); } } } diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp index 86a7e8217f7..6fb2abe7cd7 100644 --- a/clang/lib/AST/ExprConstant.cpp +++ b/clang/lib/AST/ExprConstant.cpp @@ -389,10 +389,8 @@ APValue PointerExprEvaluator::VisitConditionalOperator(ConditionalOperator *E) { } APValue PointerExprEvaluator::VisitChooseExpr(ChooseExpr *E) { - Expr* EvalExpr = E->isConditionTrue(Info.Ctx) ? E->getLHS() : E->getRHS(); - APValue Result; - if (EvaluatePointer(EvalExpr, Result, Info)) + if (EvaluatePointer(E->getChosenSubExpr(Info.Ctx), Result, Info)) return Result; return APValue(); } @@ -522,10 +520,8 @@ APValue VectorExprEvaluator::VisitConditionalOperator(const ConditionalOperator } APValue VectorExprEvaluator::VisitChooseExpr(const ChooseExpr *E) { - Expr* EvalExpr = E->isConditionTrue(Info.Ctx) ? E->getLHS() : E->getRHS(); - APValue Result; - if (EvaluateVector(EvalExpr, Result, Info)) + if (EvaluateVector(E->getChosenSubExpr(Info.Ctx), Result, Info)) return Result; return APValue(); } @@ -1185,9 +1181,7 @@ bool IntExprEvaluator::VisitCastExpr(CastExpr *E) { } bool IntExprEvaluator::VisitChooseExpr(const ChooseExpr *E) { - Expr* EvalExpr = E->isConditionTrue(Info.Ctx) ? E->getLHS() : E->getRHS(); - - return Visit(EvalExpr); + return Visit(E->getChosenSubExpr(Info.Ctx)); } bool IntExprEvaluator::VisitUnaryReal(const UnaryOperator *E) { diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp index d54c6954fb2..3ab85686752 100644 --- a/clang/lib/CodeGen/CGExpr.cpp +++ b/clang/lib/CodeGen/CGExpr.cpp @@ -178,11 +178,7 @@ LValue CodeGenFunction::EmitLValue(const Expr *E) { 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/clang/lib/CodeGen/CGExprComplex.cpp b/clang/lib/CodeGen/CGExprComplex.cpp index c676b579e65..e970ba2561c 100644 --- a/clang/lib/CodeGen/CGExprComplex.cpp +++ b/clang/lib/CodeGen/CGExprComplex.cpp @@ -509,8 +509,7 @@ VisitConditionalOperator(const ConditionalOperator *E) { } 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/clang/lib/CodeGen/CGExprScalar.cpp b/clang/lib/CodeGen/CGExprScalar.cpp index 38cc3eec5dc..9951d8794b8 100644 --- a/clang/lib/CodeGen/CGExprScalar.cpp +++ b/clang/lib/CodeGen/CGExprScalar.cpp @@ -1307,9 +1307,7 @@ VisitConditionalOperator(const ConditionalOperator *E) { } 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) { |

