[cfe-commits] r59407 - in /cfe/trunk: include/clang/Analysis/PathSensitive/Store.h lib/Analysis/BasicStore.cpp lib/Analysis/GRExprEngine.cpp lib/Analysis/RegionStore.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Sat Nov 15 23:06:26 PST 2008
Author: zhongxingxu
Date: Sun Nov 16 01:06:26 2008
New Revision: 59407
URL: http://llvm.org/viewvc/llvm-project?rev=59407&view=rev
Log:
Enhance modularization: return a <state,loc> pair to let GRExprEngine modify the
environment.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
cfe/trunk/lib/Analysis/BasicStore.cpp
cfe/trunk/lib/Analysis/GRExprEngine.cpp
cfe/trunk/lib/Analysis/RegionStore.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/Store.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/Store.h?rev=59407&r1=59406&r2=59407&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/Store.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/Store.h Sun Nov 16 01:06:26 2008
@@ -81,8 +81,8 @@
/// 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
Modified: cfe/trunk/lib/Analysis/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BasicStore.cpp?rev=59407&r1=59406&r2=59407&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/BasicStore.cpp (original)
+++ cfe/trunk/lib/Analysis/BasicStore.cpp Sun Nov 16 01:06:26 2008
@@ -66,9 +66,9 @@
/// 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());
}
Modified: cfe/trunk/lib/Analysis/GRExprEngine.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/GRExprEngine.cpp?rev=59407&r1=59406&r2=59407&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/GRExprEngine.cpp (original)
+++ cfe/trunk/lib/Analysis/GRExprEngine.cpp Sun Nov 16 01:06:26 2008
@@ -1698,11 +1698,15 @@
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;
}
}
Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=59407&r1=59406&r2=59407&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Sun Nov 16 01:06:26 2008
@@ -82,8 +82,8 @@
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 @@
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 @@
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) {
More information about the cfe-commits
mailing list