summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-01-22 23:43:57 +0000
committerTed Kremenek <kremenek@apple.com>2009-01-22 23:43:57 +0000
commitfe0f1788cacfd71a9325f578329b8c0734465020 (patch)
tree717f37bab8ae8b59364d52310d7b37d74a25b2b4 /clang/lib
parent1f9053a83ca977645ba3e005a60072cba59fcc22 (diff)
downloadbcm5719-llvm-fe0f1788cacfd71a9325f578329b8c0734465020.tar.gz
bcm5719-llvm-fe0f1788cacfd71a9325f578329b8c0734465020.zip
Add RegionStore support for the implicit object region that 'self' references. This causes tests 'ObjCProperties.m' and 'refcnt_naming.m' to now pass with RegionStore.
llvm-svn: 62814
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Analysis/RegionStore.cpp29
1 files changed, 24 insertions, 5 deletions
diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp
index 6f0ec1d0b73..ec801d47f28 100644
--- a/clang/lib/Analysis/RegionStore.cpp
+++ b/clang/lib/Analysis/RegionStore.cpp
@@ -110,13 +110,19 @@ class VISIBILITY_HIDDEN RegionStoreManager : public StoreManager {
RegionViews::Factory RVFactory;
GRStateManager& StateMgr;
+ const MemRegion* SelfRegion;
+ const ImplicitParamDecl *SelfDecl;
public:
RegionStoreManager(GRStateManager& mgr)
: StoreManager(mgr.getAllocator()),
RBFactory(mgr.getAllocator()),
RVFactory(mgr.getAllocator()),
- StateMgr(mgr) {}
+ StateMgr(mgr), SelfRegion(0), SelfDecl(0) {
+ if (const ObjCMethodDecl* MD =
+ dyn_cast<ObjCMethodDecl>(&StateMgr.getCodeDecl()))
+ SelfDecl = MD->getSelfDecl();
+ }
virtual ~RegionStoreManager() {}
@@ -187,8 +193,16 @@ public:
/// 'this' object (C++). When used when analyzing a normal function this
/// method returns NULL.
const MemRegion* getSelfRegion(Store) {
- assert (false && "Not implemented.");
- return 0;
+ if (!SelfDecl)
+ return 0;
+
+ if (!SelfRegion) {
+ const ObjCMethodDecl *MD = cast<ObjCMethodDecl>(&StateMgr.getCodeDecl());
+ SelfRegion = MRMgr.getObjCObjectRegion(MD->getClassInterface(),
+ MRMgr.getHeapRegion());
+ }
+
+ return SelfRegion;
}
/// RemoveDeadBindings - Scans the RegionStore of 'state' for dead values.
@@ -563,9 +577,14 @@ SVal RegionStoreManager::Retrieve(const GRState* St, Loc L, QualType T) {
// function/method. These are either symbolic values or 'undefined'.
// We treat function parameters as symbolic values.
- if (const VarRegion* VR = dyn_cast<VarRegion>(R))
- if (isa<ParmVarDecl>(VR->getDecl()))
+ if (const VarRegion* VR = dyn_cast<VarRegion>(R)) {
+ const VarDecl *VD = VR->getDecl();
+
+ if (isa<ParmVarDecl>(VD))
return SVal::GetRValueSymbolVal(getSymbolManager(), VR);
+ else if (VD == SelfDecl)
+ return loc::MemRegionVal(getSelfRegion(0));
+ }
if (MRMgr.onStack(R) || MRMgr.onHeap(R)) {
// All stack variables are considered to have undefined values
OpenPOWER on IntegriCloud