]> granicus.if.org Git - clang/commitdiff
Revert r303316, a change to ExprConstant to evaluate function arguments.
authorNick Lewycky <nicholas@mxc.ca>
Mon, 12 Jun 2017 21:15:44 +0000 (21:15 +0000)
committerNick Lewycky <nicholas@mxc.ca>
Mon, 12 Jun 2017 21:15:44 +0000 (21:15 +0000)
The patch was itself correct but it uncovered other bugs which are going to be difficult to fix, per PR33140.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@305233 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ExprConstant.cpp
test/Sema/integer-overflow.c

index 17d0ce67dcf9a63b872c9d1fd88ae53b1f025721..768947d00ac48c981d9d48a4fdf2a2c96cbcc455 100644 (file)
@@ -4588,7 +4588,7 @@ public:
   }
 
   bool handleCallExpr(const CallExpr *E, APValue &Result,
-                      const LValue *ResultSlot) {
+                     const LValue *ResultSlot) {
     const Expr *Callee = E->getCallee()->IgnoreParens();
     QualType CalleeType = Callee->getType();
 
@@ -4597,23 +4597,6 @@ public:
     auto Args = llvm::makeArrayRef(E->getArgs(), E->getNumArgs());
     bool HasQualifier = false;
 
-    struct EvaluateIgnoredRAII {
-    public:
-      EvaluateIgnoredRAII(EvalInfo &Info, llvm::ArrayRef<const Expr*> ToEval)
-          : Info(Info), ToEval(ToEval) {}
-      ~EvaluateIgnoredRAII() {
-        if (Info.noteFailure()) {
-          for (auto E : ToEval)
-            EvaluateIgnoredValue(Info, E);
-        }
-      }
-      void cancel() { ToEval = {}; }
-      void drop_front() { ToEval = ToEval.drop_front(); }
-    private:
-      EvalInfo &Info;
-      llvm::ArrayRef<const Expr*> ToEval;
-    } EvalArguments(Info, Args);
-
     // Extract function decl and 'this' pointer from the callee.
     if (CalleeType->isSpecificBuiltinType(BuiltinType::BoundMember)) {
       const ValueDecl *Member = nullptr;
@@ -4663,12 +4646,10 @@ public:
         if (Args.empty())
           return Error(E);
 
-        const Expr *FirstArg = Args[0];
-        Args = Args.drop_front();
-        EvalArguments.drop_front();
-        if (!EvaluateObjectArgument(Info, FirstArg, ThisVal))
+        if (!EvaluateObjectArgument(Info, Args[0], ThisVal))
           return false;
         This = &ThisVal;
+        Args = Args.slice(1);
       } else if (MD && MD->isLambdaStaticInvoker()) {   
         // Map the static invoker for the lambda back to the call operator.
         // Conveniently, we don't have to slice out the 'this' argument (as is
@@ -4720,12 +4701,8 @@ public:
     const FunctionDecl *Definition = nullptr;
     Stmt *Body = FD->getBody(Definition);
 
-    if (!CheckConstexprFunction(Info, E->getExprLoc(), FD, Definition, Body))
-      return false;
-
-    EvalArguments.cancel();
-
-    if (!HandleFunctionCall(E->getExprLoc(), Definition, This, Args, Body, Info,
+    if (!CheckConstexprFunction(Info, E->getExprLoc(), FD, Definition, Body) ||
+        !HandleFunctionCall(E->getExprLoc(), Definition, This, Args, Body, Info,
                             Result, ResultSlot))
       return false;
 
index c2b6ba209b718d570aec2763a3d94084127ec83c..62ee33e3d181961ccff27f1a4fedbbad9ec44505 100644 (file)
@@ -151,14 +151,6 @@ uint64_t check_integer_overflows(int i) {
   uint64_t *b;
   uint64_t b2 = b[4608 * 1024 * 1024] + 1;
 
-// expected-warning@+1 {{overflow in expression; result is 536870912 with type 'int'}} 
-  f0(4608 * 1024 * 1024);
-  f0(4608ul * 1024 * 1024);
-// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}} 
-  f1(4608 * 1024 * 1024, 4608 * 1024 * 1024);
-// expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}} 
-  f2(4608 * 1024 * 1024, 4608 * 1024 * 1024);
-
 // expected-warning@+1 2{{overflow in expression; result is 536870912 with type 'int'}}
   int j1 = i ? (4608 * 1024 * 1024) : (4608 * 1024 * 1024);