summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
diff options
context:
space:
mode:
authorGabor Horvath <xazax.hun@gmail.com>2015-09-11 16:55:01 +0000
committerGabor Horvath <xazax.hun@gmail.com>2015-09-11 16:55:01 +0000
commit15843343b67a37c8859bd7f84d2f34b0f7eead85 (patch)
treed78eac474e240b69e50692102685ac4a4dd54113 /clang/lib/StaticAnalyzer/Core/MemRegion.cpp
parent62921286982916bf03158f31fb053882faee7bf1 (diff)
downloadbcm5719-llvm-15843343b67a37c8859bd7f84d2f34b0f7eead85.tar.gz
bcm5719-llvm-15843343b67a37c8859bd7f84d2f34b0f7eead85.zip
[Static Analyzer] Lambda support.
Differential Revision: http://reviews.llvm.org/D12652 llvm-svn: 247426
Diffstat (limited to 'clang/lib/StaticAnalyzer/Core/MemRegion.cpp')
-rw-r--r--clang/lib/StaticAnalyzer/Core/MemRegion.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
index 78c5f4ad7af..d41fed0619e 100644
--- a/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
+++ b/clang/lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -1013,10 +1013,21 @@ MemRegionManager::getCXXBaseObjectRegion(const CXXRecordDecl *RD,
const CXXThisRegion*
MemRegionManager::getCXXThisRegion(QualType thisPointerTy,
const LocationContext *LC) {
- const StackFrameContext *STC = LC->getCurrentStackFrame();
- assert(STC);
const PointerType *PT = thisPointerTy->getAs<PointerType>();
assert(PT);
+ // Inside the body of the operator() of a lambda a this expr might refer to an
+ // object in one of the parent location contexts.
+ const auto *D = dyn_cast<CXXMethodDecl>(LC->getDecl());
+ // FIXME: when operator() of lambda is analyzed as a top level function and
+ // 'this' refers to a this to the enclosing scope, there is no right region to
+ // return.
+ while (!LC->inTopFrame() &&
+ PT != D->getThisType(getContext())->getAs<PointerType>()) {
+ LC = LC->getParent();
+ D = dyn_cast<CXXMethodDecl>(LC->getDecl());
+ }
+ const StackFrameContext *STC = LC->getCurrentStackFrame();
+ assert(STC);
return getSubRegion<CXXThisRegion>(PT, getStackArgumentsRegion(STC));
}
OpenPOWER on IntegriCloud