]> granicus.if.org Git - clang/commitdiff
Simplify: we don't care why constant evaluation might have failed when we're
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 5 Nov 2013 22:23:30 +0000 (22:23 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 5 Nov 2013 22:23:30 +0000 (22:23 +0000)
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
lib/AST/ExprConstant.cpp
lib/Sema/SemaChecking.cpp

index 04ec751b288229b1c086cdc02adb1636a7bab17e..eee304aea68f4276a92c1cb470034031ecbdeb05 100644 (file)
@@ -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<PartialDiagnosticAt> *Diag=0) const;
-  
-  void EvaluateForOverflow(const ASTContext &Ctx,
-                           SmallVectorImpl<PartialDiagnosticAt> *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.
index 01267143e517a5bf8e8be289b5f3fe87d0c87e10..cd22ff048b37f99c32ded0e56a5a8ad2ae74bec8 100644 (file)
@@ -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<PartialDiagnosticAt> *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);
index 733bd0f9bbf040572555c1adb2bcc6fbf155ac8a..b1da24b1f9bced85910be50f1a93385a7cb13954 100644 (file)
@@ -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<BinaryOperator>(E->IgnoreParens())) {
-    SmallVector<PartialDiagnosticAt, 4> Diags;
-    E->EvaluateForOverflow(Context, &Diags);
-  }
+  if (isa<BinaryOperator>(E->IgnoreParens()))
+    E->EvaluateForOverflow(Context);
 }
 
 namespace {