From 0004329758b99d2b92096b353e35c427ebbee622 Mon Sep 17 00:00:00 2001 From: Richard Smith Date: Tue, 5 Nov 2013 22:23:30 +0000 Subject: [PATCH] Simplify: we don't care why constant evaluation might have failed when we're checking an expression for constant overflow. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194099 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/Expr.h | 7 +++---- lib/AST/ExprConstant.cpp | 9 +++------ lib/Sema/SemaChecking.cpp | 6 ++---- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/include/clang/AST/Expr.h b/include/clang/AST/Expr.h index 04ec751b28..eee304aea6 100644 --- a/include/clang/AST/Expr.h +++ b/include/clang/AST/Expr.h @@ -579,15 +579,14 @@ public: /// \brief Determine whether this expression involves a call to any function /// that is not trivial. bool hasNonTrivialCall(ASTContext &Ctx); - + /// EvaluateKnownConstInt - Call EvaluateAsRValue and return the folded /// integer. This must be called on an expression that constant folds to an /// integer. llvm::APSInt EvaluateKnownConstInt(const ASTContext &Ctx, SmallVectorImpl *Diag=0) const; - - void EvaluateForOverflow(const ASTContext &Ctx, - SmallVectorImpl *Diag) const; + + void EvaluateForOverflow(const ASTContext &Ctx) const; /// EvaluateAsLValue - Evaluate an expression to see if we can fold it to an /// lvalue with link time known address, with no side-effects. diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 01267143e5..cd22ff048b 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -566,12 +566,12 @@ namespace { switch (EvalMode) { case EM_ConstantExpression: case EM_PotentialConstantExpression: - case EM_EvaluateForOverflow: HasActiveDiagnostic = false; return OptionalDiagnostic(); case EM_ConstantFold: case EM_IgnoreSideEffects: + case EM_EvaluateForOverflow: break; } } @@ -615,8 +615,7 @@ namespace { unsigned ExtraNotes = 0) { // Don't override a previous diagnostic. Don't bother collecting // diagnostics if we're evaluating for overflow. - if (!EvalStatus.Diag || !EvalStatus.Diag->empty() || - EvalMode == EM_EvaluateForOverflow) { + if (!EvalStatus.Diag || !EvalStatus.Diag->empty()) { HasActiveDiagnostic = false; return OptionalDiagnostic(); } @@ -8133,11 +8132,9 @@ APSInt Expr::EvaluateKnownConstInt(const ASTContext &Ctx, return EvalResult.Val.getInt(); } -void Expr::EvaluateForOverflow(const ASTContext &Ctx, - SmallVectorImpl *Diags) const { +void Expr::EvaluateForOverflow(const ASTContext &Ctx) const { bool IsConst; EvalResult EvalResult; - EvalResult.Diag = Diags; if (!FastEvaluateAsRValue(this, EvalResult, Ctx, IsConst)) { EvalInfo Info(Ctx, EvalResult, EvalInfo::EM_EvaluateForOverflow); (void)::EvaluateAsRValue(Info, this, EvalResult.Val); diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index 733bd0f9bb..b1da24b1f9 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -5620,10 +5620,8 @@ void Sema::CheckImplicitConversions(Expr *E, SourceLocation CC) { /// Diagnose when expression is an integer constant expression and its evaluation /// results in integer overflow void Sema::CheckForIntOverflow (Expr *E) { - if (isa(E->IgnoreParens())) { - SmallVector Diags; - E->EvaluateForOverflow(Context, &Diags); - } + if (isa(E->IgnoreParens())) + E->EvaluateForOverflow(Context); } namespace { -- 2.40.0