r251404 - [analyzer] Fix another crash when analyzing lambda functions.

Gabor Horvath via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 27 05:36:28 PDT 2015


Author: xazax
Date: Tue Oct 27 07:36:26 2015
New Revision: 251404

URL: http://llvm.org/viewvc/llvm-project?rev=251404&view=rev
Log:
[analyzer] Fix another crash when analyzing lambda functions.

Modified:
    cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
    cfe/trunk/test/Analysis/lambdas.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp?rev=251404&r1=251403&r2=251404&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp Tue Oct 27 07:36:26 2015
@@ -1022,7 +1022,8 @@ MemRegionManager::getCXXThisRegion(QualT
   // '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());
   }

Modified: cfe/trunk/test/Analysis/lambdas.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lambdas.cpp?rev=251404&r1=251403&r2=251404&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/lambdas.cpp (original)
+++ cfe/trunk/test/Analysis/lambdas.cpp Tue Oct 27 07:36:26 2015
@@ -186,6 +186,12 @@ struct DontCrash {
   int x;
   void f() {
     callLambda([&](){ ++x; });
+    callLambdaFromStatic([&](){ ++x; });
+  }
+  
+  template<typename T>
+  static void callLambdaFromStatic(T t) {
+    t();
   }
 };
 




More information about the cfe-commits mailing list