aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-06-23 18:05:21 +0000
committerTed Kremenek <kremenek@apple.com>2009-06-23 18:05:21 +0000
commitea20cd74793d257679267032419a9ff7fc89dc05 (patch)
tree8485b33ac0323bfddbb807da5eaedde9e87c2e07
parentdbc2afc5fbafcffff06da0b875ce62f364cf11e0 (diff)
Move 'hasStackStorage()' and 'hasHeapStorage()' from MemRegionManager to MemRegion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73973 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Analysis/PathSensitive/GRState.h5
-rw-r--r--include/clang/Analysis/PathSensitive/MemRegion.h8
-rw-r--r--lib/Analysis/CFRefCount.cpp2
-rw-r--r--lib/Analysis/GRExprEngine.cpp2
-rw-r--r--lib/Analysis/MemRegion.cpp16
-rw-r--r--lib/Analysis/RegionStore.cpp2
6 files changed, 15 insertions, 20 deletions
diff --git a/include/clang/Analysis/PathSensitive/GRState.h b/include/clang/Analysis/PathSensitive/GRState.h
index 2954bd4733..98f1242ad8 100644
--- a/include/clang/Analysis/PathSensitive/GRState.h
+++ b/include/clang/Analysis/PathSensitive/GRState.h
@@ -574,11 +574,6 @@ public:
// Methods that manipulate the GDM.
const GRState* addGDM(const GRState* St, void* Key, void* Data);
- // Methods that query or create regions.
- bool hasStackStorage(const MemRegion* R) {
- return getRegionManager().hasStackStorage(R);
- }
-
// Methods that query & manipulate the Store.
void iterBindings(const GRState* state, StoreManager::BindingsHandler& F) {
diff --git a/include/clang/Analysis/PathSensitive/MemRegion.h b/include/clang/Analysis/PathSensitive/MemRegion.h
index ac158dc88f..b531375be2 100644
--- a/include/clang/Analysis/PathSensitive/MemRegion.h
+++ b/include/clang/Analysis/PathSensitive/MemRegion.h
@@ -68,6 +68,10 @@ public:
virtual MemRegionManager* getMemRegionManager() const = 0;
std::string getString() const;
+
+ bool hasStackStorage() const;
+
+ bool hasHeapStorage() const;
virtual void print(llvm::raw_ostream& os) const;
@@ -668,10 +672,6 @@ public:
assert(R);
return R == globals;
}
-
- bool hasStackStorage(const MemRegion* R);
-
- bool hasHeapStorage(const MemRegion* R);
private:
MemSpaceRegion* LazyAllocate(MemSpaceRegion*& region);
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 1ccd0924f3..46333a74f2 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -3141,7 +3141,7 @@ void CFRefCount::EvalBind(GRStmtNodeBuilderRef& B, SVal location, SVal val) {
escapes = true;
else {
const MemRegion* R = cast<loc::MemRegionVal>(location).getRegion();
- escapes = !B.getStateManager().hasStackStorage(R);
+ escapes = !R->hasStackStorage();
if (!escapes) {
// To test (3), generate a new state with the binding removed. If it is
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index d5f0e406bb..7d56d108de 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -2764,7 +2764,7 @@ void GRExprEngine::VisitReturnStmt(ReturnStmt* S, NodeTy* Pred, NodeSet& Dst) {
// Determine if the value is on the stack.
const MemRegion* R = cast<loc::MemRegionVal>(&X)->getRegion();
- if (R && getStateManager().hasStackStorage(R)) {
+ if (R && R->hasStackStorage()) {
// Create a special node representing the error.
if (NodeTy* N = Builder->generateNode(S, GetState(*I), *I)) {
N->markAsSink();
diff --git a/lib/Analysis/MemRegion.cpp b/lib/Analysis/MemRegion.cpp
index 9bd93cd6eb..f018c83b91 100644
--- a/lib/Analysis/MemRegion.cpp
+++ b/lib/Analysis/MemRegion.cpp
@@ -313,17 +313,17 @@ AllocaRegion* MemRegionManager::getAllocaRegion(const Expr* E, unsigned cnt) {
return getRegion<AllocaRegion>(E, cnt);
}
-bool MemRegionManager::hasStackStorage(const MemRegion* R) {
+bool MemRegion::hasStackStorage() const {
// Only subregions can have stack storage.
- const SubRegion* SR = dyn_cast<SubRegion>(R);
+ const SubRegion* SR = dyn_cast<SubRegion>(this);
if (!SR)
return false;
- MemSpaceRegion* S = getStackRegion();
+ MemSpaceRegion* S = getMemRegionManager()->getStackRegion();
while (SR) {
- R = SR->getSuperRegion();
+ const MemRegion *R = SR->getSuperRegion();
if (R == S)
return true;
@@ -333,17 +333,17 @@ bool MemRegionManager::hasStackStorage(const MemRegion* R) {
return false;
}
-bool MemRegionManager::hasHeapStorage(const MemRegion* R) {
+bool MemRegion::hasHeapStorage() const {
// Only subregions can have stack storage.
- const SubRegion* SR = dyn_cast<SubRegion>(R);
+ const SubRegion* SR = dyn_cast<SubRegion>(this);
if (!SR)
return false;
- MemSpaceRegion* H = getHeapRegion();
+ MemSpaceRegion* H = getMemRegionManager()->getHeapRegion();
while (SR) {
- R = SR->getSuperRegion();
+ const MemRegion *R = SR->getSuperRegion();
if (R == H)
return true;
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp
index f76807beb2..17e332387f 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.hasStackStorage(R) || MRMgr.hasHeapStorage(R)) {
+ if (R->hasStackStorage() || R->hasHeapStorage()) {
// 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