diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2008-11-16 07:06:26 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2008-11-16 07:06:26 +0000 |
commit | 99a96d6ef38a391c42f514b7a4358bbb2db6c788 (patch) | |
tree | c9a8423f0f7996419e15349ea5c77be6287652f5 | |
parent | f8f6270f14fe69f4e6af489212a484289f2a7e57 (diff) | |
download | bcm5719-llvm-99a96d6ef38a391c42f514b7a4358bbb2db6c788.tar.gz bcm5719-llvm-99a96d6ef38a391c42f514b7a4358bbb2db6c788.zip |
Enhance modularization: return a <state,loc> pair to let GRExprEngine modify the
environment.
llvm-svn: 59407
-rw-r--r-- | clang/include/clang/Analysis/PathSensitive/Store.h | 4 | ||||
-rw-r--r-- | clang/lib/Analysis/BasicStore.cpp | 6 | ||||
-rw-r--r-- | clang/lib/Analysis/GRExprEngine.cpp | 8 | ||||
-rw-r--r-- | clang/lib/Analysis/RegionStore.cpp | 18 |
4 files changed, 19 insertions, 17 deletions
diff --git a/clang/include/clang/Analysis/PathSensitive/Store.h b/clang/include/clang/Analysis/PathSensitive/Store.h index 06c49cb85cc..e31b6d4ddcd 100644 --- a/clang/include/clang/Analysis/PathSensitive/Store.h +++ b/clang/include/clang/Analysis/PathSensitive/Store.h @@ -81,8 +81,8 @@ public: /// conversions between arrays and pointers. virtual SVal ArrayToPointer(SVal Array) = 0; - virtual const GRState* CastRegion(const GRState* St, SVal VoidPtr, - QualType CastToTy, Stmt* CastE) = 0; + virtual std::pair<const GRState*, SVal> + CastRegion(const GRState* St, SVal VoidPtr, QualType CastToTy, Stmt* CastE)=0; /// getSelfRegion - Returns the region for the 'self' (Objective-C) or /// 'this' object (C++). When used when analyzing a normal function this diff --git a/clang/lib/Analysis/BasicStore.cpp b/clang/lib/Analysis/BasicStore.cpp index 8b5ef6ee865..ae6febff7ba 100644 --- a/clang/lib/Analysis/BasicStore.cpp +++ b/clang/lib/Analysis/BasicStore.cpp @@ -66,9 +66,9 @@ public: /// conversions between arrays and pointers. SVal ArrayToPointer(SVal Array) { return Array; } - const GRState* CastRegion(const GRState* St, SVal VoidPtr, QualType CastToTy, - Stmt* CastE) { - return St; + std::pair<const GRState*, SVal> + CastRegion(const GRState* St, SVal VoidPtr, QualType CastToTy, Stmt* CastE) { + return std::pair<const GRState*, SVal>(St, UnknownVal()); } diff --git a/clang/lib/Analysis/GRExprEngine.cpp b/clang/lib/Analysis/GRExprEngine.cpp index e002c136372..fe7d6f94266 100644 --- a/clang/lib/Analysis/GRExprEngine.cpp +++ b/clang/lib/Analysis/GRExprEngine.cpp @@ -1698,11 +1698,15 @@ void GRExprEngine::VisitCast(Expr* CastE, Expr* Ex, NodeTy* Pred, NodeSet& Dst){ assert(Loc::IsLocType(ExTy)); // Delegate to store manager. - const GRState* NewSt = getStoreManager().CastRegion(St, V, T, CastE); + std::pair<const GRState*, SVal> Res = + getStoreManager().CastRegion(St, V, T, CastE); + + const GRState* NewSt = Res.first; + SVal NewPtr = Res.second; // If no new region is created, fall through to the default case. if (NewSt != St) { - MakeNode(Dst, CastE, N, NewSt); + MakeNode(Dst, CastE, N, BindExpr(NewSt, CastE, NewPtr)); continue; } } diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp index 732785c0f72..fab2e605383 100644 --- a/clang/lib/Analysis/RegionStore.cpp +++ b/clang/lib/Analysis/RegionStore.cpp @@ -82,8 +82,8 @@ public: SVal ArrayToPointer(SVal Array); - const GRState* CastRegion(const GRState* St, SVal VoidPtr, - QualType CastToTy, Stmt* CastE); + std::pair<const GRState*, SVal> + CastRegion(const GRState* St, SVal VoidPtr, QualType CastToTy, Stmt* CastE); SVal Retrieve(Store S, Loc L, QualType T = QualType()); @@ -264,10 +264,9 @@ SVal RegionStoreManager::ArrayToPointer(SVal Array) { return loc::MemRegionVal(ER); } -const GRState* RegionStoreManager::CastRegion(const GRState* St, - SVal VoidPtr, - QualType CastToTy, - Stmt* CastE) { +std::pair<const GRState*, SVal> +RegionStoreManager::CastRegion(const GRState* St, SVal VoidPtr, + QualType CastToTy, Stmt* CastE) { if (const AllocaRegion* AR = dyn_cast<AllocaRegion>(cast<loc::MemRegionVal>(VoidPtr).getRegion())) { @@ -278,14 +277,13 @@ const GRState* RegionStoreManager::CastRegion(const GRState* St, nonloc::ConcreteInt Idx(getBasicVals().getZeroWithPtrWidth(false)); const ElementRegion* ER = MRMgr.getElementRegion(Idx, TR); - St = StateMgr.BindExpr(St, CastE, loc::MemRegionVal(ER)); - // Add a RegionView to base region. - return AddRegionView(St, TR, AR); + return std::pair<const GRState*, SVal>(AddRegionView(St, TR, AR), + loc::MemRegionVal(ER)); } // Default case. - return St; + return std::pair<const GRState*, SVal>(St, UnknownVal()); } SVal RegionStoreManager::Retrieve(Store S, Loc L, QualType T) { |