]> granicus.if.org Git - clang/commitdiff
[analyzer] Fix another crash when analyzing lambda functions.
authorGabor Horvath <xazax.hun@gmail.com>
Tue, 27 Oct 2015 12:36:26 +0000 (12:36 +0000)
committerGabor Horvath <xazax.hun@gmail.com>
Tue, 27 Oct 2015 12:36:26 +0000 (12:36 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251404 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/MemRegion.cpp
test/Analysis/lambdas.cpp

index 86e33969d21b62fb6ef0ed0566e62709ea275daf..632a381a398e068bae9feb291b6342b7c698b79d 100644 (file)
@@ -1022,7 +1022,8 @@ MemRegionManager::getCXXThisRegion(QualType thisPointerTy,
   // 'this' refers to a this to the enclosing scope, there is no right region to
   // return.
   while (!LC->inTopFrame() &&
-         (!D || PT != D->getThisType(getContext())->getAs<PointerType>())) {
+         (!D || D->isStatic() ||
+          PT != D->getThisType(getContext())->getAs<PointerType>())) {
     LC = LC->getParent();
     D = dyn_cast<CXXMethodDecl>(LC->getDecl());
   }
index 18b2e416315bc725ae083dea28faeef0a7a865fc..36af7e1e84e445bdb894dd23b360e6f6cb393870 100644 (file)
@@ -186,6 +186,12 @@ struct DontCrash {
   int x;
   void f() {
     callLambda([&](){ ++x; });
+    callLambdaFromStatic([&](){ ++x; });
+  }
+  
+  template<typename T>
+  static void callLambdaFromStatic(T t) {
+    t();
   }
 };