aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Analysis/MemRegion.cpp36
-rw-r--r--lib/Analysis/RegionStore.cpp2
2 files changed, 21 insertions, 17 deletions
diff --git a/lib/Analysis/MemRegion.cpp b/lib/Analysis/MemRegion.cpp
index a923ac29eb..619d1617d0 100644
--- a/lib/Analysis/MemRegion.cpp
+++ b/lib/Analysis/MemRegion.cpp
@@ -234,20 +234,6 @@ MemSpaceRegion* MemRegionManager::getCodeRegion() {
return LazyAllocate(code);
}
-bool MemRegionManager::onStack(const MemRegion* R) {
- while (const SubRegion* SR = dyn_cast<SubRegion>(R))
- R = SR->getSuperRegion();
-
- return (R != 0) && (R == stack);
-}
-
-bool MemRegionManager::onHeap(const MemRegion* R) {
- while (const SubRegion* SR = dyn_cast<SubRegion>(R))
- R = SR->getSuperRegion();
-
- return (R != 0) && (R == heap);
-}
-
//===----------------------------------------------------------------------===//
// Constructing regions.
//===----------------------------------------------------------------------===//
@@ -352,7 +338,6 @@ AllocaRegion* MemRegionManager::getAllocaRegion(const Expr* E, unsigned cnt) {
}
bool MemRegionManager::hasStackStorage(const MemRegion* R) {
-
// Only subregions can have stack storage.
const SubRegion* SR = dyn_cast<SubRegion>(R);
@@ -368,10 +353,29 @@ bool MemRegionManager::hasStackStorage(const MemRegion* R) {
SR = dyn_cast<SubRegion>(R);
}
-
+
return false;
}
+bool MemRegionManager::hasHeapStorage(const MemRegion* R) {
+ // Only subregions can have stack storage.
+ const SubRegion* SR = dyn_cast<SubRegion>(R);
+
+ if (!SR)
+ return false;
+
+ MemSpaceRegion* H = getHeapRegion();
+
+ while (SR) {
+ R = SR->getSuperRegion();
+ if (R == H)
+ return true;
+
+ SR = dyn_cast<SubRegion>(R);
+ }
+
+ return false;
+}
//===----------------------------------------------------------------------===//
// View handling.
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp
index 4b598a384f..564ffec6cf 100644
--- a/lib/Analysis/RegionStore.cpp
+++ b/lib/Analysis/RegionStore.cpp
@@ -939,7 +939,7 @@ SVal RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
}
}
- if (MRMgr.onStack(R) || MRMgr.onHeap(R)) {
+ if (MRMgr.hasStackStorage(R) || MRMgr.hasHeapStorage(R)) {
// 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