[cfe-commits] r95360 - in /cfe/trunk: include/clang/Checker/PathSensitive/GRState.h include/clang/Checker/PathSensitive/Store.h lib/Checker/BasicStore.cpp lib/Checker/CFRefCount.cpp lib/Checker/FlatStore.cpp lib/Checker/RegionStore.cpp lib/Checker/Store.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Thu Feb 4 21:06:22 PST 2010
Author: zhongxingxu
Date: Thu Feb 4 23:06:13 2010
New Revision: 95360
URL: http://llvm.org/viewvc/llvm-project?rev=95360&view=rev
Log:
More GRState* -> Store changes.
Modified:
cfe/trunk/include/clang/Checker/PathSensitive/GRState.h
cfe/trunk/include/clang/Checker/PathSensitive/Store.h
cfe/trunk/lib/Checker/BasicStore.cpp
cfe/trunk/lib/Checker/CFRefCount.cpp
cfe/trunk/lib/Checker/FlatStore.cpp
cfe/trunk/lib/Checker/RegionStore.cpp
cfe/trunk/lib/Checker/Store.cpp
Modified: cfe/trunk/include/clang/Checker/PathSensitive/GRState.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/GRState.h?rev=95360&r1=95359&r2=95360&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/GRState.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/GRState.h Thu Feb 4 23:06:13 2010
@@ -216,7 +216,7 @@
/// in 'state' plus the bindings for the CompoundLiteral. 'R' is the region
/// for the compound literal and 'BegInit' and 'EndInit' represent an
/// array of initializer values.
- const GRState* bindCompoundLiteral(const CompoundLiteralExpr* CL,
+ const GRState *bindCompoundLiteral(const CompoundLiteralExpr* CL,
const LocationContext *LC,
SVal V) const;
@@ -607,19 +607,24 @@
inline const GRState *
GRState::bindCompoundLiteral(const CompoundLiteralExpr* CL,
const LocationContext *LC, SVal V) const {
- return getStateManager().StoreMgr->BindCompoundLiteral(this, CL, LC, V);
+ Store new_store =
+ getStateManager().StoreMgr->BindCompoundLiteral(St, CL, LC, V);
+ return makeWithStore(new_store);
}
inline const GRState *GRState::bindDecl(const VarRegion* VR, SVal IVal) const {
- return getStateManager().StoreMgr->BindDecl(this, VR, IVal);
+ Store new_store = getStateManager().StoreMgr->BindDecl(St, VR, IVal);
+ return makeWithStore(new_store);
}
inline const GRState *GRState::bindDeclWithNoInit(const VarRegion* VR) const {
- return getStateManager().StoreMgr->BindDeclWithNoInit(this, VR);
+ Store new_store = getStateManager().StoreMgr->BindDeclWithNoInit(St, VR);
+ return makeWithStore(new_store);
}
inline const GRState *GRState::bindLoc(Loc LV, SVal V) const {
- return getStateManager().StoreMgr->Bind(this, LV, V);
+ Store new_store = getStateManager().StoreMgr->Bind(St, LV, V);
+ return makeWithStore(new_store);
}
inline const GRState *GRState::bindLoc(SVal LV, SVal V) const {
Modified: cfe/trunk/include/clang/Checker/PathSensitive/Store.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/Store.h?rev=95360&r1=95359&r2=95360&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/Store.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/Store.h Thu Feb 4 23:06:13 2010
@@ -63,7 +63,7 @@
/// \return A pointer to a GRState object that contains the same bindings as
/// \c state with the addition of having the value specified by \c val bound
/// to the location given for \c loc.
- virtual const GRState *Bind(const GRState *state, Loc loc, SVal val) = 0;
+ virtual Store Bind(Store store, Loc loc, SVal val) = 0;
virtual Store Remove(Store St, Loc L) = 0;
@@ -71,10 +71,9 @@
/// in 'store' plus the bindings for the CompoundLiteral. 'R' is the region
/// for the compound literal and 'BegInit' and 'EndInit' represent an
/// array of initializer values.
- virtual const GRState *BindCompoundLiteral(const GRState *state,
- const CompoundLiteralExpr* cl,
- const LocationContext *LC,
- SVal v) = 0;
+ virtual Store BindCompoundLiteral(Store store,
+ const CompoundLiteralExpr* cl,
+ const LocationContext *LC, SVal v) = 0;
/// getInitialStore - Returns the initial "empty" store representing the
/// value bindings upon entry to an analyzed function.
@@ -137,24 +136,22 @@
SymbolReaper& SymReaper,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) = 0;
- virtual const GRState *BindDecl(const GRState *ST, const VarRegion *VR,
- SVal initVal) = 0;
+ virtual Store BindDecl(Store store, const VarRegion *VR, SVal initVal) = 0;
- virtual const GRState *BindDeclWithNoInit(const GRState *ST,
- const VarRegion *VR) = 0;
+ virtual Store BindDeclWithNoInit(Store store, const VarRegion *VR) = 0;
typedef llvm::DenseSet<SymbolRef> InvalidatedSymbols;
- virtual const GRState *InvalidateRegion(const GRState *state,
- const MemRegion *R,
- const Expr *E, unsigned Count,
- InvalidatedSymbols *IS) = 0;
+ virtual Store InvalidateRegion(Store store,
+ const MemRegion *R,
+ const Expr *E, unsigned Count,
+ InvalidatedSymbols *IS) = 0;
- virtual const GRState *InvalidateRegions(const GRState *state,
- const MemRegion * const *Begin,
- const MemRegion * const *End,
- const Expr *E, unsigned Count,
- InvalidatedSymbols *IS);
+ virtual Store InvalidateRegions(Store store,
+ const MemRegion * const *Begin,
+ const MemRegion * const *End,
+ const Expr *E, unsigned Count,
+ InvalidatedSymbols *IS);
// FIXME: Make out-of-line.
virtual const GRState *setExtent(const GRState *state,
Modified: cfe/trunk/lib/Checker/BasicStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/BasicStore.cpp?rev=95360&r1=95359&r2=95360&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/BasicStore.cpp (original)
+++ cfe/trunk/lib/Checker/BasicStore.cpp Thu Feb 4 23:06:13 2010
@@ -46,12 +46,11 @@
SVal Retrieve(Store store, Loc loc, QualType T = QualType());
- const GRState *InvalidateRegion(const GRState *state, const MemRegion *R,
- const Expr *E, unsigned Count,
- InvalidatedSymbols *IS);
+ Store InvalidateRegion(Store store, const MemRegion *R, const Expr *E,
+ unsigned Count, InvalidatedSymbols *IS);
- const GRState *Bind(const GRState *state, Loc L, SVal V) {
- return state->makeWithStore(BindInternal(state->getStore(), L, V));
+ Store Bind(Store store, Loc L, SVal V) {
+ return BindInternal(store, L, V);
}
Store scanForIvars(Stmt *B, const Decl* SelfDecl,
@@ -66,11 +65,9 @@
return ValMgr.makeLoc(MRMgr.getVarRegion(VD, LC));
}
- const GRState *BindCompoundLiteral(const GRState *state,
- const CompoundLiteralExpr*,
- const LocationContext*,
- SVal val) {
- return state;
+ Store BindCompoundLiteral(Store store, const CompoundLiteralExpr*,
+ const LocationContext*, SVal val) {
+ return store;
}
SVal getLValueVar(const VarDecl *VD, const LocationContext *LC);
@@ -90,14 +87,12 @@
void iterBindings(Store store, BindingsHandler& f);
- const GRState *BindDecl(const GRState *state, const VarRegion *VR,
- SVal InitVal) {
- return state->makeWithStore(BindDeclInternal(state->getStore(), VR,
- &InitVal));
+ Store BindDecl(Store store, const VarRegion *VR, SVal InitVal) {
+ return BindDeclInternal(store, VR, &InitVal);
}
- const GRState *BindDeclWithNoInit(const GRState *state, const VarRegion *VR) {
- return state->makeWithStore(BindDeclInternal(state->getStore(), VR, 0));
+ Store BindDeclWithNoInit(Store store, const VarRegion *VR) {
+ return BindDeclInternal(store, VR, 0);
}
Store BindDeclInternal(Store store, const VarRegion *VR, SVal *InitVal);
@@ -596,18 +591,18 @@
// Binding invalidation.
//===----------------------------------------------------------------------===//
-const GRState *BasicStoreManager::InvalidateRegion(const GRState *state,
- const MemRegion *R,
- const Expr *E,
- unsigned Count,
- InvalidatedSymbols *IS) {
+Store BasicStoreManager::InvalidateRegion(Store store,
+ const MemRegion *R,
+ const Expr *E,
+ unsigned Count,
+ InvalidatedSymbols *IS) {
R = R->StripCasts();
if (!(isa<VarRegion>(R) || isa<ObjCIvarRegion>(R)))
- return state;
+ return store;
if (IS) {
- BindingsTy B = GetBindings(state->getStore());
+ BindingsTy B = GetBindings(store);
if (BindingsTy::data_type *Val = B.lookup(R)) {
if (SymbolRef Sym = Val->getAsSymbol())
IS->insert(Sym);
@@ -616,6 +611,6 @@
QualType T = cast<TypedRegion>(R)->getValueType(R->getContext());
SVal V = ValMgr.getConjuredSymbolVal(R, E, T, Count);
- return Bind(state, loc::MemRegionVal(R), V);
+ return Bind(store, loc::MemRegionVal(R), V);
}
Modified: cfe/trunk/lib/Checker/CFRefCount.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/CFRefCount.cpp?rev=95360&r1=95359&r2=95360&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/CFRefCount.cpp (original)
+++ cfe/trunk/lib/Checker/CFRefCount.cpp Thu Feb 4 23:06:13 2010
@@ -2683,10 +2683,12 @@
StoreManager::InvalidatedSymbols IS;
- state = StoreMgr.InvalidateRegions(state, RegionsToInvalidate.data(),
+ Store store = state->getStore();
+ store = StoreMgr.InvalidateRegions(store, RegionsToInvalidate.data(),
RegionsToInvalidate.data() +
RegionsToInvalidate.size(),
Ex, Count, &IS);
+ state = state->makeWithStore(store);
for (StoreManager::InvalidatedSymbols::iterator I = IS.begin(),
E = IS.end(); I!=E; ++I) {
// Remove any existing reference-count binding.
Modified: cfe/trunk/lib/Checker/FlatStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/FlatStore.cpp?rev=95360&r1=95359&r2=95360&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/FlatStore.cpp (original)
+++ cfe/trunk/lib/Checker/FlatStore.cpp Thu Feb 4 23:06:13 2010
@@ -28,12 +28,10 @@
BVFactory(mgr.getAllocator()) {}
SVal Retrieve(Store store, Loc loc, QualType T);
- const GRState *Bind(const GRState *state, Loc loc, SVal val);
+ Store Bind(Store store, Loc loc, SVal val);
Store Remove(Store St, Loc L);
- const GRState *BindCompoundLiteral(const GRState *state,
- const CompoundLiteralExpr* cl,
- const LocationContext *LC,
- SVal v);
+ Store BindCompoundLiteral(Store store, const CompoundLiteralExpr* cl,
+ const LocationContext *LC, SVal v);
Store getInitialStore(const LocationContext *InitLoc) {
return RBFactory.GetEmptyMap().getRoot();
@@ -52,16 +50,14 @@
SymbolReaper& SymReaper,
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots);
- const GRState *BindDecl(const GRState *ST, const VarRegion *VR, SVal initVal);
+ Store BindDecl(Store store, const VarRegion *VR, SVal initVal);
- const GRState *BindDeclWithNoInit(const GRState *ST, const VarRegion *VR);
+ Store BindDeclWithNoInit(Store store, const VarRegion *VR);
typedef llvm::DenseSet<SymbolRef> InvalidatedSymbols;
- const GRState *InvalidateRegion(const GRState *state,
- const MemRegion *R,
- const Expr *E, unsigned Count,
- InvalidatedSymbols *IS);
+ Store InvalidateRegion(Store store, const MemRegion *R, const Expr *E,
+ unsigned Count, InvalidatedSymbols *IS);
void print(Store store, llvm::raw_ostream& Out, const char* nl,
const char *sep);
@@ -77,19 +73,19 @@
return UnknownVal();
}
-const GRState *FlatStoreManager::Bind(const GRState *state, Loc loc, SVal val) {
- return state;
+Store FlatStoreManager::Bind(Store store, Loc loc, SVal val) {
+ return store;
}
Store FlatStoreManager::Remove(Store store, Loc L) {
return store;
}
-const GRState *FlatStoreManager::BindCompoundLiteral(const GRState *state,
- const CompoundLiteralExpr* cl,
- const LocationContext *LC,
- SVal v) {
- return state;
+Store FlatStoreManager::BindCompoundLiteral(Store store,
+ const CompoundLiteralExpr* cl,
+ const LocationContext *LC,
+ SVal v) {
+ return store;
}
@@ -128,21 +124,19 @@
llvm::SmallVectorImpl<const MemRegion*>& RegionRoots) {
}
-const GRState *FlatStoreManager::BindDecl(const GRState *state,
- const VarRegion *VR, SVal initVal) {
- return state;
+Store FlatStoreManager::BindDecl(Store store, const VarRegion *VR,
+ SVal initVal) {
+ return store;
}
-const GRState *FlatStoreManager::BindDeclWithNoInit(const GRState *state,
- const VarRegion *VR) {
- return state;
+Store FlatStoreManager::BindDeclWithNoInit(Store store, const VarRegion *VR) {
+ return store;
}
-const GRState *FlatStoreManager::InvalidateRegion(const GRState *state,
- const MemRegion *R,
- const Expr *E, unsigned Count,
- InvalidatedSymbols *IS) {
- return state;
+Store FlatStoreManager::InvalidateRegion(Store store, const MemRegion *R,
+ const Expr *E, unsigned Count,
+ InvalidatedSymbols *IS) {
+ return store;
}
void FlatStoreManager::print(Store store, llvm::raw_ostream& Out,
Modified: cfe/trunk/lib/Checker/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/RegionStore.cpp?rev=95360&r1=95359&r2=95360&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/RegionStore.cpp (original)
+++ cfe/trunk/lib/Checker/RegionStore.cpp Thu Feb 4 23:06:13 2010
@@ -228,9 +228,7 @@
/// setImplicitDefaultValue - Set the default binding for the provided
/// MemRegion to the value implicitly defined for compound literals when
/// the value is not specified.
- const GRState *setImplicitDefaultValue(const GRState *state,
- const MemRegion *R,
- QualType T);
+ Store setImplicitDefaultValue(Store store, const MemRegion *R, QualType T);
/// getLValueString - Returns an SVal representing the lvalue of a
/// StringLiteral. Within RegionStore a StringLiteral has an
@@ -277,17 +275,16 @@
// Binding values to regions.
//===-------------------------------------------------------------------===//
- const GRState *InvalidateRegion(const GRState *state, const MemRegion *R,
- const Expr *E, unsigned Count,
- InvalidatedSymbols *IS) {
- return RegionStoreManager::InvalidateRegions(state, &R, &R+1, E, Count, IS);
+ Store InvalidateRegion(Store store, const MemRegion *R, const Expr *E,
+ unsigned Count, InvalidatedSymbols *IS) {
+ return RegionStoreManager::InvalidateRegions(store, &R, &R+1, E, Count, IS);
}
- const GRState *InvalidateRegions(const GRState *state,
- const MemRegion * const *Begin,
- const MemRegion * const *End,
- const Expr *E, unsigned Count,
- InvalidatedSymbols *IS);
+ Store InvalidateRegions(Store store,
+ const MemRegion * const *Begin,
+ const MemRegion * const *End,
+ const Expr *E, unsigned Count,
+ InvalidatedSymbols *IS);
public: // Made public for helper classes.
@@ -314,25 +311,21 @@
public: // Part of public interface to class.
- const GRState *Bind(const GRState *state, Loc LV, SVal V);
+ Store Bind(Store store, Loc LV, SVal V);
- const GRState *BindCompoundLiteral(const GRState *state,
- const CompoundLiteralExpr* CL,
- const LocationContext *LC,
- SVal V);
-
- const GRState *BindDecl(const GRState *ST, const VarRegion *VR,
- SVal InitVal);
-
- const GRState *BindDeclWithNoInit(const GRState *state,
- const VarRegion *) {
- return state;
+ Store BindCompoundLiteral(Store store, const CompoundLiteralExpr* CL,
+ const LocationContext *LC, SVal V);
+
+ Store BindDecl(Store store, const VarRegion *VR, SVal InitVal);
+
+ Store BindDeclWithNoInit(Store store, const VarRegion *) {
+ return store;
}
/// BindStruct - Bind a compound value to a structure.
- const GRState *BindStruct(const GRState *, const TypedRegion* R, SVal V);
+ Store BindStruct(Store store, const TypedRegion* R, SVal V);
- const GRState *BindArray(const GRState *state, const TypedRegion* R, SVal V);
+ Store BindArray(Store store, const TypedRegion* R, SVal V);
/// KillStruct - Set the entire struct to unknown.
Store KillStruct(Store store, const TypedRegion* R);
@@ -383,9 +376,8 @@
std::pair<Store, const MemRegion*>
GetLazyBinding(RegionBindings B, const MemRegion *R);
- const GRState* CopyLazyBindings(nonloc::LazyCompoundVal V,
- const GRState *state,
- const TypedRegion *R);
+ Store CopyLazyBindings(nonloc::LazyCompoundVal V, Store store,
+ const TypedRegion *R);
const ElementRegion *GetElementZeroRegion(const SymbolicRegion *SR,
QualType T);
@@ -514,13 +506,11 @@
ClusterMap ClusterM;
WorkList WL;
public:
- const GRState *InvalidateRegions(RegionStoreManager &RM,
- const GRState *state,
- const MemRegion * const *I,
- const MemRegion * const *E,
- const Expr *Ex,
- unsigned Count,
- StoreManager::InvalidatedSymbols *IS);
+ Store InvalidateRegions(RegionStoreManager &RM, Store store,
+ const MemRegion * const *I,const MemRegion * const *E,
+ const Expr *Ex, unsigned Count,
+ StoreManager::InvalidatedSymbols *IS,
+ ASTContext &Ctx, ValueManager &ValMgr);
private:
void AddToWorkList(BindingKey K);
@@ -561,17 +551,15 @@
return &CRef;
}
-const GRState *
-InvalidateRegionsWorker::InvalidateRegions(RegionStoreManager &RM,
- const GRState *state,
- const MemRegion * const *I,
- const MemRegion * const *E,
- const Expr *Ex, unsigned Count,
- StoreManager::InvalidatedSymbols *IS)
-{
- ASTContext &Ctx = state->getStateManager().getContext();
- ValueManager &ValMgr = state->getStateManager().getValueManager();
- RegionBindings B = RegionStoreManager::GetRegionBindings(state->getStore());
+Store InvalidateRegionsWorker::InvalidateRegions(RegionStoreManager &RM,
+ Store store,
+ const MemRegion * const *I,
+ const MemRegion * const *E,
+ const Expr *Ex, unsigned Count,
+ StoreManager::InvalidatedSymbols *IS,
+ ASTContext &Ctx,
+ ValueManager &ValMgr) {
+ RegionBindings B = RegionStoreManager::GetRegionBindings(store);
// Scan the entire store and make the region clusters.
for (RegionBindings::iterator RI = B.begin(), RE = B.end(); RI != RE; ++RI) {
@@ -677,17 +665,17 @@
}
// Create a new state with the updated bindings.
- return state->makeWithStore(B.getRoot());
+ return B.getRoot();
}
-const GRState *RegionStoreManager::InvalidateRegions(const GRState *state,
- const MemRegion * const *I,
- const MemRegion * const *E,
- const Expr *Ex,
- unsigned Count,
- InvalidatedSymbols *IS) {
+Store RegionStoreManager::InvalidateRegions(Store store,
+ const MemRegion * const *I,
+ const MemRegion * const *E,
+ const Expr *Ex, unsigned Count,
+ InvalidatedSymbols *IS) {
InvalidateRegionsWorker W;
- return W.InvalidateRegions(*this, state, I, E, Ex, Count, IS);
+ return W.InvalidateRegions(*this, store, I, E, Ex, Count, IS, getContext(),
+ StateMgr.getValueManager());
}
@@ -1491,9 +1479,9 @@
return store;
}
-const GRState *RegionStoreManager::Bind(const GRState *state, Loc L, SVal V) {
+Store RegionStoreManager::Bind(Store store, Loc L, SVal V) {
if (isa<loc::ConcreteInt>(L))
- return state;
+ return store;
// If we get here, the location should be a region.
const MemRegion *R = cast<loc::MemRegionVal>(L).getRegion();
@@ -1501,7 +1489,7 @@
// Check if the region is a struct region.
if (const TypedRegion* TR = dyn_cast<TypedRegion>(R))
if (TR->getValueType(getContext())->isStructureType())
- return BindStruct(state, TR, V);
+ return BindStruct(store, TR, V);
// Special case: the current region represents a cast and it and the super
// region both have pointer types or intptr_t types. If so, perform the
@@ -1519,12 +1507,12 @@
if (IsAnyPointerOrIntptr(superTy, Ctx) &&
IsAnyPointerOrIntptr(erTy, Ctx)) {
V = ValMgr.getSValuator().EvalCast(V, superTy, erTy);
- return Bind(state, loc::MemRegionVal(superR), V);
+ return Bind(store, loc::MemRegionVal(superR), V);
}
// For now, just invalidate the fields of the struct/union/class.
// FIXME: Precisely handle the fields of the record.
if (superTy->isRecordType())
- return InvalidateRegion(state, superR, NULL, 0, NULL);
+ return InvalidateRegion(store, superR, NULL, 0, NULL);
}
}
}
@@ -1543,38 +1531,35 @@
}
// Perform the binding.
- RegionBindings B = GetRegionBindings(state->getStore());
- return state->makeWithStore(Add(B, R, BindingKey::Direct, V).getRoot());
+ RegionBindings B = GetRegionBindings(store);
+ return Add(B, R, BindingKey::Direct, V).getRoot();
}
-const GRState *RegionStoreManager::BindDecl(const GRState *ST,
- const VarRegion *VR,
- SVal InitVal) {
+Store RegionStoreManager::BindDecl(Store store, const VarRegion *VR,
+ SVal InitVal) {
QualType T = VR->getDecl()->getType();
if (T->isArrayType())
- return BindArray(ST, VR, InitVal);
+ return BindArray(store, VR, InitVal);
if (T->isStructureType())
- return BindStruct(ST, VR, InitVal);
+ return BindStruct(store, VR, InitVal);
- return Bind(ST, ValMgr.makeLoc(VR), InitVal);
+ return Bind(store, ValMgr.makeLoc(VR), InitVal);
}
// FIXME: this method should be merged into Bind().
-const GRState *
-RegionStoreManager::BindCompoundLiteral(const GRState *state,
- const CompoundLiteralExpr *CL,
- const LocationContext *LC,
- SVal V) {
- return Bind(state, loc::MemRegionVal(MRMgr.getCompoundLiteralRegion(CL, LC)),
+Store RegionStoreManager::BindCompoundLiteral(Store store,
+ const CompoundLiteralExpr *CL,
+ const LocationContext *LC,
+ SVal V) {
+ return Bind(store, loc::MemRegionVal(MRMgr.getCompoundLiteralRegion(CL, LC)),
V);
}
-const GRState *RegionStoreManager::setImplicitDefaultValue(const GRState *state,
- const MemRegion *R,
- QualType T) {
- Store store = state->getStore();
+Store RegionStoreManager::setImplicitDefaultValue(Store store,
+ const MemRegion *R,
+ QualType T) {
RegionBindings B = GetRegionBindings(store);
SVal V;
@@ -1588,15 +1573,14 @@
V = ValMgr.makeZeroVal(ValMgr.getContext().IntTy);
}
else {
- return state;
+ return store;
}
- return state->makeWithStore(Add(B, R, BindingKey::Default, V).getRoot());
+ return Add(B, R, BindingKey::Default, V).getRoot();
}
-const GRState *RegionStoreManager::BindArray(const GRState *state,
- const TypedRegion* R,
- SVal Init) {
+Store RegionStoreManager::BindArray(Store store, const TypedRegion* R,
+ SVal Init) {
ASTContext &Ctx = getContext();
const ArrayType *AT =
@@ -1632,20 +1616,20 @@
getContext());
SVal V = ValMgr.makeIntVal(str[j], sizeof(char)*8, true);
- state = Bind(state, loc::MemRegionVal(ER), V);
+ store = Bind(store, loc::MemRegionVal(ER), V);
}
- return state;
+ return store;
}
// Handle lazy compound values.
if (nonloc::LazyCompoundVal *LCV = dyn_cast<nonloc::LazyCompoundVal>(&Init))
- return CopyLazyBindings(*LCV, state, R);
+ return CopyLazyBindings(*LCV, store, R);
// Remaining case: explicit compound values.
if (Init.isUnknown())
- return setImplicitDefaultValue(state, R, ElementTy);
+ return setImplicitDefaultValue(store, R, ElementTy);
nonloc::CompoundVal& CV = cast<nonloc::CompoundVal>(Init);
nonloc::CompoundVal::iterator VI = CV.begin(), VE = CV.end();
@@ -1660,25 +1644,24 @@
const ElementRegion *ER = MRMgr.getElementRegion(ElementTy, Idx, R, getContext());
if (ElementTy->isStructureType())
- state = BindStruct(state, ER, *VI);
+ store = BindStruct(store, ER, *VI);
else
- state = Bind(state, ValMgr.makeLoc(ER), *VI);
+ store = Bind(store, ValMgr.makeLoc(ER), *VI);
}
// If the init list is shorter than the array length, set the
// array default value.
if (Size.hasValue() && i < Size.getValue())
- state = setImplicitDefaultValue(state, R, ElementTy);
+ store = setImplicitDefaultValue(store, R, ElementTy);
- return state;
+ return store;
}
-const GRState *
-RegionStoreManager::BindStruct(const GRState *state, const TypedRegion* R,
- SVal V) {
+Store RegionStoreManager::BindStruct(Store store, const TypedRegion* R,
+ SVal V) {
if (!Features.supportsFields())
- return state;
+ return store;
QualType T = R->getValueType(getContext());
assert(T->isStructureType());
@@ -1687,16 +1670,16 @@
RecordDecl* RD = RT->getDecl();
if (!RD->isDefinition())
- return state;
+ return store;
// Handle lazy compound values.
if (const nonloc::LazyCompoundVal *LCV=dyn_cast<nonloc::LazyCompoundVal>(&V))
- return CopyLazyBindings(*LCV, state, R);
+ return CopyLazyBindings(*LCV, store, R);
// We may get non-CompoundVal accidentally due to imprecise cast logic.
// Ignore them and kill the field values.
if (V.isUnknown() || !isa<nonloc::CompoundVal>(V))
- return state->makeWithStore(KillStruct(state->getStore(), R));
+ return KillStruct(store, R);
nonloc::CompoundVal& CV = cast<nonloc::CompoundVal>(V);
nonloc::CompoundVal::iterator VI = CV.begin(), VE = CV.end();
@@ -1712,22 +1695,21 @@
const FieldRegion* FR = MRMgr.getFieldRegion(*FI, R);
if (FTy->isArrayType())
- state = BindArray(state, FR, *VI);
+ store = BindArray(store, FR, *VI);
else if (FTy->isStructureType())
- state = BindStruct(state, FR, *VI);
+ store = BindStruct(store, FR, *VI);
else
- state = Bind(state, ValMgr.makeLoc(FR), *VI);
+ store = Bind(store, ValMgr.makeLoc(FR), *VI);
}
// There may be fewer values in the initialize list than the fields of struct.
if (FI != FE) {
- Store store = state->getStore();
RegionBindings B = GetRegionBindings(store);
B = Add(B, R, BindingKey::Default, ValMgr.makeIntVal(0, false));
- state = state->makeWithStore(B.getRoot());
+ store = B.getRoot();
}
- return state;
+ return store;
}
Store RegionStoreManager::KillStruct(Store store, const TypedRegion* R) {
@@ -1740,23 +1722,21 @@
return Add(B, R, BindingKey::Default, UnknownVal()).getRoot();
}
-const GRState*
-RegionStoreManager::CopyLazyBindings(nonloc::LazyCompoundVal V,
- const GRState *state,
- const TypedRegion *R) {
+Store RegionStoreManager::CopyLazyBindings(nonloc::LazyCompoundVal V,
+ Store store, const TypedRegion *R) {
// Nuke the old bindings stemming from R.
- RegionBindings B = GetRegionBindings(state->getStore());
+ RegionBindings B = GetRegionBindings(store);
llvm::OwningPtr<RegionStoreSubRegionMap>
- SubRegions(getRegionStoreSubRegionMap(state->getStore()));
+ SubRegions(getRegionStoreSubRegionMap(store));
// B and DVM are updated after the call to RemoveSubRegionBindings.
RemoveSubRegionBindings(B, R, *SubRegions.get());
// Now copy the bindings. This amounts to just binding 'V' to 'R'. This
// results in a zero-copy algorithm.
- return state->makeWithStore(Add(B, R, BindingKey::Direct, V).getRoot());
+ return Add(B, R, BindingKey::Direct, V).getRoot();
}
//===----------------------------------------------------------------------===//
@@ -2024,12 +2004,13 @@
CallExpr::const_arg_iterator AI = CE->arg_begin(), AE = CE->arg_end();
// Copy the arg expression value to the arg variables.
+ Store store = state->getStore();
for (; AI != AE; ++AI, ++PI) {
SVal ArgVal = state->getSVal(*AI);
- state = Bind(state, ValMgr.makeLoc(MRMgr.getVarRegion(*PI, frame)), ArgVal);
+ store = Bind(store, ValMgr.makeLoc(MRMgr.getVarRegion(*PI, frame)), ArgVal);
}
- return state;
+ return state->makeWithStore(store);
}
//===----------------------------------------------------------------------===//
Modified: cfe/trunk/lib/Checker/Store.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/Store.cpp?rev=95360&r1=95359&r2=95360&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/Store.cpp (original)
+++ cfe/trunk/lib/Checker/Store.cpp Thu Feb 4 23:06:13 2010
@@ -224,16 +224,15 @@
return V;
}
-const GRState *StoreManager::InvalidateRegions(const GRState *state,
- const MemRegion * const *I,
- const MemRegion * const *End,
- const Expr *E,
- unsigned Count,
- InvalidatedSymbols *IS) {
+Store StoreManager::InvalidateRegions(Store store,
+ const MemRegion * const *I,
+ const MemRegion * const *End,
+ const Expr *E, unsigned Count,
+ InvalidatedSymbols *IS) {
for ( ; I != End ; ++I)
- state = InvalidateRegion(state, *I, E, Count, IS);
+ store = InvalidateRegion(store, *I, E, Count, IS);
- return state;
+ return store;
}
//===----------------------------------------------------------------------===//
More information about the cfe-commits
mailing list