Index: lib/AST/ExprConstant.cpp =================================================================== --- lib/AST/ExprConstant.cpp +++ lib/AST/ExprConstant.cpp @@ -4466,6 +4466,8 @@ { return StmtVisitorTy::Visit(E->getSubExpr()); } bool VisitUnaryPlus(const UnaryOperator *E) { return StmtVisitorTy::Visit(E->getSubExpr()); } + bool VisitObjCBoxedExpr(const ObjCBoxedExpr *E) + { return StmtVisitorTy::Visit(E->getSubExpr()); } bool VisitChooseExpr(const ChooseExpr *E) { return StmtVisitorTy::Visit(E->getChosenSubExpr()); } bool VisitGenericSelectionExpr(const GenericSelectionExpr *E) @@ -5471,7 +5473,26 @@ bool VisitObjCStringLiteral(const ObjCStringLiteral *E) { return Success(E); } bool VisitObjCBoxedExpr(const ObjCBoxedExpr *E) - { return Success(E); } + { + // Should we continue evaluation after determining the result value? + switch (Info.EvalMode) { + case EvalInfo::EM_PotentialConstantExpression: + case EvalInfo::EM_PotentialConstantExpressionUnevaluated: + case EvalInfo::EM_EvaluateForOverflow: + case EvalInfo::EM_IgnoreSideEffects: + if (!E->getSubExpr()->isValueDependent()) { + APValue Discard; + Evaluate(Discard, Info, E->getSubExpr()); + } + + case EvalInfo::EM_ConstantExpression: + case EvalInfo::EM_ConstantExpressionUnevaluated: + case EvalInfo::EM_ConstantFold: + case EvalInfo::EM_OffsetFold: + return Success(E); + } + llvm_unreachable("Missed EvalMode case"); + } bool VisitAddrLabelExpr(const AddrLabelExpr *E) { return Success(E); } bool VisitCallExpr(const CallExpr *E); Index: lib/Sema/SemaChecking.cpp =================================================================== --- lib/Sema/SemaChecking.cpp +++ lib/Sema/SemaChecking.cpp @@ -9882,6 +9882,9 @@ if (auto InitList = dyn_cast(E)) Exprs.append(InitList->inits().begin(), InitList->inits().end()); + + if (isa(E)) + E->IgnoreParenCasts()->EvaluateForOverflow(Context); } while (!Exprs.empty()); } Index: lib/Sema/SemaExprObjC.cpp =================================================================== --- lib/Sema/SemaExprObjC.cpp +++ lib/Sema/SemaExprObjC.cpp @@ -595,7 +595,6 @@ break; } } - CheckForIntOverflow(ValueExpr); // FIXME: Do I need to do anything special with BoolTy expressions? // Look for the appropriate method within NSNumber.