зеркало из https://github.com/microsoft/clang-1.git
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:
Родитель
dbc2afc5fb
Коммит
ea20cd7479
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче