From: Gabor Horvath Date: Tue, 27 Oct 2015 12:36:26 +0000 (+0000) Subject: [analyzer] Fix another crash when analyzing lambda functions. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=11ee3485f60c821b117e8673ae40b2c8572e4f19;p=clang [analyzer] Fix another crash when analyzing lambda functions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251404 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/MemRegion.cpp b/lib/StaticAnalyzer/Core/MemRegion.cpp index 86e33969d2..632a381a39 100644 --- a/lib/StaticAnalyzer/Core/MemRegion.cpp +++ b/lib/StaticAnalyzer/Core/MemRegion.cpp @@ -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())) { + (!D || D->isStatic() || + PT != D->getThisType(getContext())->getAs())) { LC = LC->getParent(); D = dyn_cast(LC->getDecl()); } diff --git a/test/Analysis/lambdas.cpp b/test/Analysis/lambdas.cpp index 18b2e41631..36af7e1e84 100644 --- a/test/Analysis/lambdas.cpp +++ b/test/Analysis/lambdas.cpp @@ -186,6 +186,12 @@ struct DontCrash { int x; void f() { callLambda([&](){ ++x; }); + callLambdaFromStatic([&](){ ++x; }); + } + + template + static void callLambdaFromStatic(T t) { + t(); } };