diff options
author | Ted Kremenek <kremenek@apple.com> | 2012-12-06 07:17:13 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2012-12-06 07:17:13 +0000 |
commit | 24570c4c258545f8310e4bc96503a5668982cf67 (patch) | |
tree | 53bb9a9d0153f2aa43ef383d898945879fea4ae0 /lib/StaticAnalyzer/Core/MemRegion.cpp | |
parent | e0c6c67d670588508da2d343193cfe2845bef7e0 (diff) |
Pull logic to map from VarDecl* to captured region using a helper function. WIP.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169479 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/StaticAnalyzer/Core/MemRegion.cpp')
-rw-r--r-- | lib/StaticAnalyzer/Core/MemRegion.cpp | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/lib/StaticAnalyzer/Core/MemRegion.cpp b/lib/StaticAnalyzer/Core/MemRegion.cpp index 0655cc1acf..70bb965859 100644 --- a/lib/StaticAnalyzer/Core/MemRegion.cpp +++ b/lib/StaticAnalyzer/Core/MemRegion.cpp @@ -1209,6 +1209,29 @@ RegionOffset MemRegion::getAsOffset() const { // BlockDataRegion //===----------------------------------------------------------------------===// +std::pair<const VarRegion *, const VarRegion *> +BlockDataRegion::getCaptureRegions(const VarDecl *VD) { + MemRegionManager &MemMgr = *getMemRegionManager(); + const VarRegion *VR = 0; + const VarRegion *OriginalVR = 0; + + if (!VD->getAttr<BlocksAttr>() && VD->hasLocalStorage()) { + VR = MemMgr.getVarRegion(VD, this); + OriginalVR = MemMgr.getVarRegion(VD, LC); + } + else { + if (LC) { + VR = MemMgr.getVarRegion(VD, LC); + OriginalVR = VR; + } + else { + VR = MemMgr.getVarRegion(VD, MemMgr.getUnknownRegion()); + OriginalVR = MemMgr.getVarRegion(VD, LC); + } + } + return std::make_pair(VR, OriginalVR); +} + void BlockDataRegion::LazyInitializeReferencedVars() { if (ReferencedVars) return; @@ -1233,25 +1256,9 @@ void BlockDataRegion::LazyInitializeReferencedVars() { new (BVOriginal) VarVec(BC, E - I); for ( ; I != E; ++I) { - const VarDecl *VD = *I; const VarRegion *VR = 0; const VarRegion *OriginalVR = 0; - - if (!VD->getAttr<BlocksAttr>() && VD->hasLocalStorage()) { - VR = MemMgr.getVarRegion(VD, this); - OriginalVR = MemMgr.getVarRegion(VD, LC); - } - else { - if (LC) { - VR = MemMgr.getVarRegion(VD, LC); - OriginalVR = VR; - } - else { - VR = MemMgr.getVarRegion(VD, MemMgr.getUnknownRegion()); - OriginalVR = MemMgr.getVarRegion(VD, LC); - } - } - + llvm::tie(VR, OriginalVR) = getCaptureRegions(*I); assert(VR); assert(OriginalVR); BV->push_back(VR, BC); |