diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Analysis/MemRegion.cpp | 49 | ||||
-rw-r--r-- | clang/lib/Analysis/RegionStore.cpp | 2 |
2 files changed, 23 insertions, 28 deletions
diff --git a/clang/lib/Analysis/MemRegion.cpp b/clang/lib/Analysis/MemRegion.cpp index f018c83b910..c8e027579a3 100644 --- a/clang/lib/Analysis/MemRegion.cpp +++ b/clang/lib/Analysis/MemRegion.cpp @@ -313,45 +313,40 @@ AllocaRegion* MemRegionManager::getAllocaRegion(const Expr* E, unsigned cnt) { return getRegion<AllocaRegion>(E, cnt); } -bool MemRegion::hasStackStorage() const { - // Only subregions can have stack storage. - const SubRegion* SR = dyn_cast<SubRegion>(this); - - if (!SR) - return false; - MemSpaceRegion* S = getMemRegionManager()->getStackRegion(); +const MemSpaceRegion *MemRegion::getMemorySpace() const { + const MemRegion *R = this; + const SubRegion* SR = dyn_cast<SubRegion>(this); while (SR) { - const MemRegion *R = SR->getSuperRegion(); - if (R == S) - return true; - - SR = dyn_cast<SubRegion>(R); + R = SR->getSuperRegion(); + SR = dyn_cast<SubRegion>(R); } - - return false; + + return dyn_cast<MemSpaceRegion>(R); } -bool MemRegion::hasHeapStorage() const { - // Only subregions can have stack storage. - const SubRegion* SR = dyn_cast<SubRegion>(this); +bool MemRegion::hasStackStorage() const { + if (const MemSpaceRegion *MS = getMemorySpace()) + return MS == getMemRegionManager()->getStackRegion(); - if (!SR) - return false; + return false; +} - MemSpaceRegion* H = getMemRegionManager()->getHeapRegion(); +bool MemRegion::hasHeapStorage() const { + if (const MemSpaceRegion *MS = getMemorySpace()) + return MS == getMemRegionManager()->getHeapRegion(); - while (SR) { - const MemRegion *R = SR->getSuperRegion(); - if (R == H) - return true; + return false; +} - SR = dyn_cast<SubRegion>(R); +bool MemRegion::hasHeapOrStackStorage() const { + if (const MemSpaceRegion *MS = getMemorySpace()) { + MemRegionManager *Mgr = getMemRegionManager(); + return MS == Mgr->getHeapRegion() || MS == Mgr->getStackRegion(); } - return false; -} +} //===----------------------------------------------------------------------===// // View handling. diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp index 17e332387f7..77f5b7cb39b 100644 --- a/clang/lib/Analysis/RegionStore.cpp +++ b/clang/lib/Analysis/RegionStore.cpp @@ -939,7 +939,7 @@ SVal RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) { } } - if (R->hasStackStorage() || R->hasHeapStorage()) { + if (R->hasHeapOrStackStorage()) { // All stack variables are considered to have undefined values // upon creation. All heap allocated blocks are considered to // have undefined values as well unless they are explicitly bound |