[cfe-commits] r74716 - in /cfe/trunk: include/clang/Analysis/PathSensitive/MemRegion.h lib/Analysis/BasicStore.cpp lib/Analysis/MemRegion.cpp lib/Analysis/RegionStore.cpp
Ted Kremenek
kremenek at apple.com
Thu Jul 2 11:25:24 PDT 2009
Author: kremenek
Date: Thu Jul 2 13:25:09 2009
New Revision: 74716
URL: http://llvm.org/viewvc/llvm-project?rev=74716&view=rev
Log:
StoreManagers: Use 'hasGlobalsStorage()' and 'hasParametersStorage()' instead of
directly consulting if a VarDecl is an implicit or actual parameter, a global,
etc.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
cfe/trunk/lib/Analysis/BasicStore.cpp
cfe/trunk/lib/Analysis/MemRegion.cpp
cfe/trunk/lib/Analysis/RegionStore.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h?rev=74716&r1=74715&r2=74716&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h Thu Jul 2 13:25:09 2009
@@ -72,6 +72,12 @@
bool hasStackStorage() const;
+ bool hasParametersStorage() const;
+
+ bool hasGlobalsStorage() const;
+
+ bool hasGlobalsOrParametersStorage() const;
+
bool hasHeapStorage() const;
bool hasHeapOrStackStorage() const;
Modified: cfe/trunk/lib/Analysis/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicStore.cpp?rev=74716&r1=74715&r2=74716&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Thu Jul 2 13:25:09 2009
@@ -528,10 +528,9 @@
// 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);
}
Modified: cfe/trunk/lib/Analysis/MemRegion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/MemRegion.cpp?rev=74716&r1=74715&r2=74716&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/MemRegion.cpp (original)
+++ cfe/trunk/lib/Analysis/MemRegion.cpp Thu Jul 2 13:25:09 2009
@@ -359,7 +359,23 @@
|| 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.
Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=74716&r1=74715&r2=74716&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Thu Jul 2 13:25:09 2009
@@ -882,8 +882,7 @@
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);
More information about the cfe-commits
mailing list