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
This commit is contained in:
Ted Kremenek 2009-06-23 18:05:21 +00:00
Родитель dbc2afc5fb
Коммит ea20cd7479
6 изменённых файлов: 15 добавлений и 20 удалений

Просмотреть файл

@ -574,11 +574,6 @@ public:
// Methods that manipulate the GDM. // Methods that manipulate the GDM.
const GRState* addGDM(const GRState* St, void* Key, void* Data); 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. // Methods that query & manipulate the Store.
void iterBindings(const GRState* state, StoreManager::BindingsHandler& F) { void iterBindings(const GRState* state, StoreManager::BindingsHandler& F) {

Просмотреть файл

@ -68,6 +68,10 @@ public:
virtual MemRegionManager* getMemRegionManager() const = 0; virtual MemRegionManager* getMemRegionManager() const = 0;
std::string getString() const; std::string getString() const;
bool hasStackStorage() const;
bool hasHeapStorage() const;
virtual void print(llvm::raw_ostream& os) const; virtual void print(llvm::raw_ostream& os) const;
@ -668,10 +672,6 @@ public:
assert(R); assert(R);
return R == globals; return R == globals;
} }
bool hasStackStorage(const MemRegion* R);
bool hasHeapStorage(const MemRegion* R);
private: private:
MemSpaceRegion* LazyAllocate(MemSpaceRegion*& region); MemSpaceRegion* LazyAllocate(MemSpaceRegion*& region);

Просмотреть файл

@ -3141,7 +3141,7 @@ void CFRefCount::EvalBind(GRStmtNodeBuilderRef& B, SVal location, SVal val) {
escapes = true; escapes = true;
else { else {
const MemRegion* R = cast<loc::MemRegionVal>(location).getRegion(); const MemRegion* R = cast<loc::MemRegionVal>(location).getRegion();
escapes = !B.getStateManager().hasStackStorage(R); escapes = !R->hasStackStorage();
if (!escapes) { if (!escapes) {
// To test (3), generate a new state with the binding removed. If it is // To test (3), generate a new state with the binding removed. If it is

Просмотреть файл

@ -2764,7 +2764,7 @@ void GRExprEngine::VisitReturnStmt(ReturnStmt* S, NodeTy* Pred, NodeSet& Dst) {
// Determine if the value is on the stack. // Determine if the value is on the stack.
const MemRegion* R = cast<loc::MemRegionVal>(&X)->getRegion(); const MemRegion* R = cast<loc::MemRegionVal>(&X)->getRegion();
if (R && getStateManager().hasStackStorage(R)) { if (R && R->hasStackStorage()) {
// Create a special node representing the error. // Create a special node representing the error.
if (NodeTy* N = Builder->generateNode(S, GetState(*I), *I)) { if (NodeTy* N = Builder->generateNode(S, GetState(*I), *I)) {
N->markAsSink(); N->markAsSink();

Просмотреть файл

@ -313,17 +313,17 @@ AllocaRegion* MemRegionManager::getAllocaRegion(const Expr* E, unsigned cnt) {
return getRegion<AllocaRegion>(E, cnt); return getRegion<AllocaRegion>(E, cnt);
} }
bool MemRegionManager::hasStackStorage(const MemRegion* R) { bool MemRegion::hasStackStorage() const {
// Only subregions can have stack storage. // Only subregions can have stack storage.
const SubRegion* SR = dyn_cast<SubRegion>(R); const SubRegion* SR = dyn_cast<SubRegion>(this);
if (!SR) if (!SR)
return false; return false;
MemSpaceRegion* S = getStackRegion(); MemSpaceRegion* S = getMemRegionManager()->getStackRegion();
while (SR) { while (SR) {
R = SR->getSuperRegion(); const MemRegion *R = SR->getSuperRegion();
if (R == S) if (R == S)
return true; return true;
@ -333,17 +333,17 @@ bool MemRegionManager::hasStackStorage(const MemRegion* R) {
return false; return false;
} }
bool MemRegionManager::hasHeapStorage(const MemRegion* R) { bool MemRegion::hasHeapStorage() const {
// Only subregions can have stack storage. // Only subregions can have stack storage.
const SubRegion* SR = dyn_cast<SubRegion>(R); const SubRegion* SR = dyn_cast<SubRegion>(this);
if (!SR) if (!SR)
return false; return false;
MemSpaceRegion* H = getHeapRegion(); MemSpaceRegion* H = getMemRegionManager()->getHeapRegion();
while (SR) { while (SR) {
R = SR->getSuperRegion(); const MemRegion *R = SR->getSuperRegion();
if (R == H) if (R == H)
return true; return true;

Просмотреть файл

@ -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 // All stack variables are considered to have undefined values
// upon creation. All heap allocated blocks are considered to // upon creation. All heap allocated blocks are considered to
// have undefined values as well unless they are explicitly bound // have undefined values as well unless they are explicitly bound