]> granicus.if.org Git - clang/commitdiff
[analyzer] Older version of GCC 4.7 crash on lambdas in default arguments.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 9 Jul 2016 12:16:58 +0000 (12:16 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 9 Jul 2016 12:16:58 +0000 (12:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@274975 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Checkers/MallocOverflowSecurityChecker.cpp

index 4060f01582a879826b75ca935ccbd9919b95e06b..fc2ab1d6e3f7d3f6ded20722a889366d5a64f4a9 100644 (file)
@@ -141,15 +141,15 @@ private:
       return false;
     }
 
-    const Decl *getDecl(const DeclRefExpr *DR) { return DR->getDecl(); }
-
-    const Decl *getDecl(const MemberExpr *ME) { return ME->getMemberDecl(); }
+    static const Decl *getDecl(const DeclRefExpr *DR) { return DR->getDecl(); }
+    static const Decl *getDecl(const MemberExpr *ME) {
+      return ME->getMemberDecl();
+    }
 
     template <typename T1>
     void Erase(const T1 *DR,
-               llvm::function_ref<bool(const MallocOverflowCheck &)> Pred =
-                   [](const MallocOverflowCheck &) { return true; }) {
-      auto P = [this, DR, Pred](const MallocOverflowCheck &Check) {
+               llvm::function_ref<bool(const MallocOverflowCheck &)> Pred) {
+      auto P = [DR, Pred](const MallocOverflowCheck &Check) {
         if (const auto *CheckDR = dyn_cast<T1>(Check.variable))
           return getDecl(CheckDR) == getDecl(DR) && Pred(Check);
         return false;
@@ -159,11 +159,12 @@ private:
     }
 
     void CheckExpr(const Expr *E_p) {
+      auto PredTrue = [](const MallocOverflowCheck &) { return true; };
       const Expr *E = E_p->IgnoreParenImpCasts();
       if (const DeclRefExpr *DR = dyn_cast<DeclRefExpr>(E))
-        Erase<DeclRefExpr>(DR);
+        Erase<DeclRefExpr>(DR, PredTrue);
       else if (const auto *ME = dyn_cast<MemberExpr>(E)) {
-        Erase<MemberExpr>(ME);
+        Erase<MemberExpr>(ME, PredTrue);
       }
     }