diff options
-rw-r--r-- | include/clang/Analysis/PathSensitive/MemRegion.h | 6 | ||||
-rw-r--r-- | lib/Analysis/BasicStore.cpp | 7 | ||||
-rw-r--r-- | lib/Analysis/MemRegion.cpp | 18 | ||||
-rw-r--r-- | lib/Analysis/RegionStore.cpp | 3 |
4 files changed, 27 insertions, 7 deletions
diff --git a/include/clang/Analysis/PathSensitive/MemRegion.h b/include/clang/Analysis/PathSensitive/MemRegion.h index 432702c089..dd850dad9d 100644 --- a/include/clang/Analysis/PathSensitive/MemRegion.h +++ b/include/clang/Analysis/PathSensitive/MemRegion.h @@ -72,6 +72,12 @@ public: bool hasStackStorage() const; + bool hasParametersStorage() const; + + bool hasGlobalsStorage() const; + + bool hasGlobalsOrParametersStorage() const; + bool hasHeapStorage() const; bool hasHeapOrStackStorage() const; diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp index d96ef5b948..ccaffc3627 100644 --- a/lib/Analysis/BasicStore.cpp +++ b/lib/Analysis/BasicStore.cpp @@ -528,10 +528,9 @@ Store BasicStoreManager::getInitialStore() { // Initialize globals and parameters to symbolic values. // Initialize local variables to undefined. const MemRegion *R = ValMgr.getRegionManager().getVarRegion(VD); - SVal X = (VD->hasGlobalStorage() || isa<ParmVarDecl>(VD) || - isa<ImplicitParamDecl>(VD)) - ? ValMgr.getRegionValueSymbolVal(R) - : UndefinedVal(); + SVal X = R->hasGlobalsOrParametersStorage() + ? ValMgr.getRegionValueSymbolVal(R) + : UndefinedVal(); St = BindInternal(St, ValMgr.makeLoc(R), X); } diff --git a/lib/Analysis/MemRegion.cpp b/lib/Analysis/MemRegion.cpp index 9314b1ec77..52e26238d9 100644 --- a/lib/Analysis/MemRegion.cpp +++ b/lib/Analysis/MemRegion.cpp @@ -359,7 +359,23 @@ bool MemRegion::hasHeapOrStackStorage() const { || MS == Mgr->getStackArgumentsRegion(); } return false; -} +} + +bool MemRegion::hasGlobalsStorage() const { + if (const MemSpaceRegion *MS = getMemorySpace()) + return MS == getMemRegionManager()->getGlobalsRegion(); + + return false; +} + +bool MemRegion::hasGlobalsOrParametersStorage() const { + if (const MemSpaceRegion *MS = getMemorySpace()) { + MemRegionManager *Mgr = getMemRegionManager(); + return MS == Mgr->getGlobalsRegion() + || MS == Mgr->getStackArgumentsRegion(); + } + return false; +} //===----------------------------------------------------------------------===// // View handling. diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp index dc9a2be628..9c76265fa3 100644 --- a/lib/Analysis/RegionStore.cpp +++ b/lib/Analysis/RegionStore.cpp @@ -882,8 +882,7 @@ SVal RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) { if (VD == SelfDecl) return loc::MemRegionVal(getSelfRegion(0)); - if (isa<ParmVarDecl>(VD) || isa<ImplicitParamDecl>(VD) || - VD->hasGlobalStorage()) { + if (VR->hasGlobalsOrParametersStorage()) { QualType VTy = VD->getType(); if (Loc::IsLocType(VTy) || VTy->isIntegerType()) return ValMgr.getRegionValueSymbolVal(VR); |