зеркало из https://github.com/microsoft/clang.git
More GRState* -> Store changes.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95357 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
bfcaf8048d
Коммит
576bb92057
|
@ -671,11 +671,11 @@ inline SVal GRState::getSValAsScalarOrLoc(const Stmt *S) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
inline SVal GRState::getSVal(Loc LV, QualType T) const {
|
inline SVal GRState::getSVal(Loc LV, QualType T) const {
|
||||||
return getStateManager().StoreMgr->Retrieve(this, LV, T);
|
return getStateManager().StoreMgr->Retrieve(St, LV, T);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline SVal GRState::getSVal(const MemRegion* R) const {
|
inline SVal GRState::getSVal(const MemRegion* R) const {
|
||||||
return getStateManager().StoreMgr->Retrieve(this, loc::MemRegionVal(R));
|
return getStateManager().StoreMgr->Retrieve(St, loc::MemRegionVal(R));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline BasicValueFactory &GRState::getBasicVals() const {
|
inline BasicValueFactory &GRState::getBasicVals() const {
|
||||||
|
|
|
@ -54,8 +54,7 @@ public:
|
||||||
/// expected type of the returned value. This is used if the value is
|
/// expected type of the returned value. This is used if the value is
|
||||||
/// lazily computed.
|
/// lazily computed.
|
||||||
/// \return The value bound to the location \c loc.
|
/// \return The value bound to the location \c loc.
|
||||||
virtual SVal Retrieve(const GRState *state, Loc loc, QualType T = QualType())
|
virtual SVal Retrieve(Store store, Loc loc, QualType T = QualType()) = 0;
|
||||||
= 0;
|
|
||||||
|
|
||||||
/// Return a state with the specified value bound to the given location.
|
/// Return a state with the specified value bound to the given location.
|
||||||
/// \param[in] state The analysis state.
|
/// \param[in] state The analysis state.
|
||||||
|
|
|
@ -44,7 +44,7 @@ public:
|
||||||
return new BasicStoreSubRegionMap();
|
return new BasicStoreSubRegionMap();
|
||||||
}
|
}
|
||||||
|
|
||||||
SVal Retrieve(const GRState *state, Loc loc, QualType T = QualType());
|
SVal Retrieve(Store store, Loc loc, QualType T = QualType());
|
||||||
|
|
||||||
const GRState *InvalidateRegion(const GRState *state, const MemRegion *R,
|
const GRState *InvalidateRegion(const GRState *state, const MemRegion *R,
|
||||||
const Expr *E, unsigned Count,
|
const Expr *E, unsigned Count,
|
||||||
|
@ -249,7 +249,7 @@ static bool isHigherOrderRawPtr(QualType T, ASTContext &C) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SVal BasicStoreManager::Retrieve(const GRState *state, Loc loc, QualType T) {
|
SVal BasicStoreManager::Retrieve(Store store, Loc loc, QualType T) {
|
||||||
if (isa<UnknownVal>(loc))
|
if (isa<UnknownVal>(loc))
|
||||||
return UnknownVal();
|
return UnknownVal();
|
||||||
|
|
||||||
|
@ -263,7 +263,7 @@ SVal BasicStoreManager::Retrieve(const GRState *state, Loc loc, QualType T) {
|
||||||
if (!(isa<VarRegion>(R) || isa<ObjCIvarRegion>(R)))
|
if (!(isa<VarRegion>(R) || isa<ObjCIvarRegion>(R)))
|
||||||
return UnknownVal();
|
return UnknownVal();
|
||||||
|
|
||||||
BindingsTy B = GetBindings(state->getStore());
|
BindingsTy B = GetBindings(store);
|
||||||
BindingsTy::data_type *Val = B.lookup(R);
|
BindingsTy::data_type *Val = B.lookup(R);
|
||||||
|
|
||||||
if (!Val)
|
if (!Val)
|
||||||
|
@ -394,7 +394,7 @@ BasicStoreManager::RemoveDeadBindings(GRState &state, Stmt* Loc,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
Marked.insert(MR);
|
Marked.insert(MR);
|
||||||
SVal X = Retrieve(&state, loc::MemRegionVal(MR));
|
SVal X = Retrieve(state.getStore(), loc::MemRegionVal(MR));
|
||||||
|
|
||||||
// FIXME: We need to handle symbols nested in region definitions.
|
// FIXME: We need to handle symbols nested in region definitions.
|
||||||
for (symbol_iterator SI=X.symbol_begin(),SE=X.symbol_end();SI!=SE;++SI)
|
for (symbol_iterator SI=X.symbol_begin(),SE=X.symbol_end();SI!=SE;++SI)
|
||||||
|
|
|
@ -27,7 +27,7 @@ public:
|
||||||
RBFactory(mgr.getAllocator()),
|
RBFactory(mgr.getAllocator()),
|
||||||
BVFactory(mgr.getAllocator()) {}
|
BVFactory(mgr.getAllocator()) {}
|
||||||
|
|
||||||
SVal Retrieve(const GRState *state, Loc loc, QualType T);
|
SVal Retrieve(Store store, Loc loc, QualType T);
|
||||||
const GRState *Bind(const GRState *state, Loc loc, SVal val);
|
const GRState *Bind(const GRState *state, Loc loc, SVal val);
|
||||||
Store Remove(Store St, Loc L);
|
Store Remove(Store St, Loc L);
|
||||||
const GRState *BindCompoundLiteral(const GRState *state,
|
const GRState *BindCompoundLiteral(const GRState *state,
|
||||||
|
@ -73,7 +73,7 @@ StoreManager *clang::CreateFlatStoreManager(GRStateManager &StMgr) {
|
||||||
return new FlatStoreManager(StMgr);
|
return new FlatStoreManager(StMgr);
|
||||||
}
|
}
|
||||||
|
|
||||||
SVal FlatStoreManager::Retrieve(const GRState *state, Loc loc, QualType T) {
|
SVal FlatStoreManager::Retrieve(Store store, Loc loc, QualType T) {
|
||||||
return UnknownVal();
|
return UnknownVal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -355,17 +355,17 @@ public: // Part of public interface to class.
|
||||||
/// return undefined
|
/// return undefined
|
||||||
/// else
|
/// else
|
||||||
/// return symbolic
|
/// return symbolic
|
||||||
SVal Retrieve(const GRState *state, Loc L, QualType T = QualType());
|
SVal Retrieve(Store store, Loc L, QualType T = QualType());
|
||||||
|
|
||||||
SVal RetrieveElement(Store store, const ElementRegion *R);
|
SVal RetrieveElement(Store store, const ElementRegion *R);
|
||||||
|
|
||||||
SVal RetrieveField(Store store, const FieldRegion *R);
|
SVal RetrieveField(Store store, const FieldRegion *R);
|
||||||
|
|
||||||
SVal RetrieveObjCIvar(const GRState *state, const ObjCIvarRegion *R);
|
SVal RetrieveObjCIvar(Store store, const ObjCIvarRegion *R);
|
||||||
|
|
||||||
SVal RetrieveVar(const GRState *state, const VarRegion *R);
|
SVal RetrieveVar(Store store, const VarRegion *R);
|
||||||
|
|
||||||
SVal RetrieveLazySymbol(const GRState *state, const TypedRegion *R);
|
SVal RetrieveLazySymbol(const TypedRegion *R);
|
||||||
|
|
||||||
SVal RetrieveFieldOrElementCommon(Store store, const TypedRegion *R,
|
SVal RetrieveFieldOrElementCommon(Store store, const TypedRegion *R,
|
||||||
QualType Ty, const MemRegion *superR);
|
QualType Ty, const MemRegion *superR);
|
||||||
|
@ -375,9 +375,9 @@ public: // Part of public interface to class.
|
||||||
/// struct s x, y;
|
/// struct s x, y;
|
||||||
/// x = y;
|
/// x = y;
|
||||||
/// y's value is retrieved by this method.
|
/// y's value is retrieved by this method.
|
||||||
SVal RetrieveStruct(const GRState *St, const TypedRegion* R);
|
SVal RetrieveStruct(Store store, const TypedRegion* R);
|
||||||
|
|
||||||
SVal RetrieveArray(const GRState *St, const TypedRegion* R);
|
SVal RetrieveArray(Store store, const TypedRegion* R);
|
||||||
|
|
||||||
/// Get the state and region whose binding this region R corresponds to.
|
/// Get the state and region whose binding this region R corresponds to.
|
||||||
std::pair<Store, const MemRegion*>
|
std::pair<Store, const MemRegion*>
|
||||||
|
@ -1095,7 +1095,7 @@ RegionStoreManager::GetElementZeroRegion(const SymbolicRegion *SR, QualType T) {
|
||||||
return MRMgr.getElementRegion(T, idx, SR, Ctx);
|
return MRMgr.getElementRegion(T, idx, SR, Ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
SVal RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
|
SVal RegionStoreManager::Retrieve(Store store, Loc L, QualType T) {
|
||||||
assert(!isa<UnknownVal>(L) && "location unknown");
|
assert(!isa<UnknownVal>(L) && "location unknown");
|
||||||
assert(!isa<UndefinedVal>(L) && "location undefined");
|
assert(!isa<UndefinedVal>(L) && "location undefined");
|
||||||
|
|
||||||
|
@ -1147,21 +1147,21 @@ SVal RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (RTy->isStructureType())
|
if (RTy->isStructureType())
|
||||||
return RetrieveStruct(state, R);
|
return RetrieveStruct(store, R);
|
||||||
|
|
||||||
// FIXME: Handle unions.
|
// FIXME: Handle unions.
|
||||||
if (RTy->isUnionType())
|
if (RTy->isUnionType())
|
||||||
return UnknownVal();
|
return UnknownVal();
|
||||||
|
|
||||||
if (RTy->isArrayType())
|
if (RTy->isArrayType())
|
||||||
return RetrieveArray(state, R);
|
return RetrieveArray(store, R);
|
||||||
|
|
||||||
// FIXME: handle Vector types.
|
// FIXME: handle Vector types.
|
||||||
if (RTy->isVectorType())
|
if (RTy->isVectorType())
|
||||||
return UnknownVal();
|
return UnknownVal();
|
||||||
|
|
||||||
if (const FieldRegion* FR = dyn_cast<FieldRegion>(R))
|
if (const FieldRegion* FR = dyn_cast<FieldRegion>(R))
|
||||||
return CastRetrievedVal(RetrieveField(state->getStore(), FR), FR, T, false);
|
return CastRetrievedVal(RetrieveField(store, FR), FR, T, false);
|
||||||
|
|
||||||
if (const ElementRegion* ER = dyn_cast<ElementRegion>(R)) {
|
if (const ElementRegion* ER = dyn_cast<ElementRegion>(R)) {
|
||||||
// FIXME: Here we actually perform an implicit conversion from the loaded
|
// FIXME: Here we actually perform an implicit conversion from the loaded
|
||||||
|
@ -1169,7 +1169,7 @@ SVal RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
|
||||||
// more intelligently. For example, an 'element' can encompass multiple
|
// more intelligently. For example, an 'element' can encompass multiple
|
||||||
// bound regions (e.g., several bound bytes), or could be a subset of
|
// bound regions (e.g., several bound bytes), or could be a subset of
|
||||||
// a larger value.
|
// a larger value.
|
||||||
return CastRetrievedVal(RetrieveElement(state->getStore(), ER), ER, T, false);
|
return CastRetrievedVal(RetrieveElement(store, ER), ER, T, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const ObjCIvarRegion *IVR = dyn_cast<ObjCIvarRegion>(R)) {
|
if (const ObjCIvarRegion *IVR = dyn_cast<ObjCIvarRegion>(R)) {
|
||||||
|
@ -1179,7 +1179,7 @@ SVal RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
|
||||||
// reinterpretted, it is possible we stored a different value that could
|
// reinterpretted, it is possible we stored a different value that could
|
||||||
// fit within the ivar. Either we need to cast these when storing them
|
// fit within the ivar. Either we need to cast these when storing them
|
||||||
// or reinterpret them lazily (as we do here).
|
// or reinterpret them lazily (as we do here).
|
||||||
return CastRetrievedVal(RetrieveObjCIvar(state, IVR), IVR, T, false);
|
return CastRetrievedVal(RetrieveObjCIvar(store, IVR), IVR, T, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (const VarRegion *VR = dyn_cast<VarRegion>(R)) {
|
if (const VarRegion *VR = dyn_cast<VarRegion>(R)) {
|
||||||
|
@ -1189,10 +1189,10 @@ SVal RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
|
||||||
// variable is reinterpretted, it is possible we stored a different value
|
// variable is reinterpretted, it is possible we stored a different value
|
||||||
// that could fit within the variable. Either we need to cast these when
|
// that could fit within the variable. Either we need to cast these when
|
||||||
// storing them or reinterpret them lazily (as we do here).
|
// storing them or reinterpret them lazily (as we do here).
|
||||||
return CastRetrievedVal(RetrieveVar(state, VR), VR, T, false);
|
return CastRetrievedVal(RetrieveVar(store, VR), VR, T, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
RegionBindings B = GetRegionBindings(state->getStore());
|
RegionBindings B = GetRegionBindings(store);
|
||||||
const SVal *V = Lookup(B, R, BindingKey::Direct);
|
const SVal *V = Lookup(B, R, BindingKey::Direct);
|
||||||
|
|
||||||
// Check if the region has a binding.
|
// Check if the region has a binding.
|
||||||
|
@ -1378,11 +1378,10 @@ SVal RegionStoreManager::RetrieveFieldOrElementCommon(Store store,
|
||||||
return ValMgr.getRegionValueSymbolVal(R, Ty);
|
return ValMgr.getRegionValueSymbolVal(R, Ty);
|
||||||
}
|
}
|
||||||
|
|
||||||
SVal RegionStoreManager::RetrieveObjCIvar(const GRState* state,
|
SVal RegionStoreManager::RetrieveObjCIvar(Store store, const ObjCIvarRegion* R){
|
||||||
const ObjCIvarRegion* R) {
|
|
||||||
|
|
||||||
// Check if the region has a binding.
|
// Check if the region has a binding.
|
||||||
RegionBindings B = GetRegionBindings(state->getStore());
|
RegionBindings B = GetRegionBindings(store);
|
||||||
|
|
||||||
if (Optional<SVal> V = getDirectBinding(B, R))
|
if (Optional<SVal> V = getDirectBinding(B, R))
|
||||||
return *V;
|
return *V;
|
||||||
|
@ -1398,14 +1397,13 @@ SVal RegionStoreManager::RetrieveObjCIvar(const GRState* state,
|
||||||
return UnknownVal();
|
return UnknownVal();
|
||||||
}
|
}
|
||||||
|
|
||||||
return RetrieveLazySymbol(state, R);
|
return RetrieveLazySymbol(R);
|
||||||
}
|
}
|
||||||
|
|
||||||
SVal RegionStoreManager::RetrieveVar(const GRState *state,
|
SVal RegionStoreManager::RetrieveVar(Store store, const VarRegion *R) {
|
||||||
const VarRegion *R) {
|
|
||||||
|
|
||||||
// Check if the region has a binding.
|
// Check if the region has a binding.
|
||||||
RegionBindings B = GetRegionBindings(state->getStore());
|
RegionBindings B = GetRegionBindings(store);
|
||||||
|
|
||||||
if (Optional<SVal> V = getDirectBinding(B, R))
|
if (Optional<SVal> V = getDirectBinding(B, R))
|
||||||
return *V;
|
return *V;
|
||||||
|
@ -1420,8 +1418,7 @@ SVal RegionStoreManager::RetrieveVar(const GRState *state,
|
||||||
return UndefinedVal();
|
return UndefinedVal();
|
||||||
}
|
}
|
||||||
|
|
||||||
SVal RegionStoreManager::RetrieveLazySymbol(const GRState *state,
|
SVal RegionStoreManager::RetrieveLazySymbol(const TypedRegion *R) {
|
||||||
const TypedRegion *R) {
|
|
||||||
|
|
||||||
QualType valTy = R->getValueType(getContext());
|
QualType valTy = R->getValueType(getContext());
|
||||||
|
|
||||||
|
@ -1429,8 +1426,7 @@ SVal RegionStoreManager::RetrieveLazySymbol(const GRState *state,
|
||||||
return ValMgr.getRegionValueSymbolVal(R, valTy);
|
return ValMgr.getRegionValueSymbolVal(R, valTy);
|
||||||
}
|
}
|
||||||
|
|
||||||
SVal RegionStoreManager::RetrieveStruct(const GRState *state,
|
SVal RegionStoreManager::RetrieveStruct(Store store, const TypedRegion* R) {
|
||||||
const TypedRegion* R) {
|
|
||||||
QualType T = R->getValueType(getContext());
|
QualType T = R->getValueType(getContext());
|
||||||
assert(T->isStructureType());
|
assert(T->isStructureType());
|
||||||
|
|
||||||
|
@ -1450,18 +1446,17 @@ SVal RegionStoreManager::RetrieveStruct(const GRState *state,
|
||||||
Field != FieldEnd; ++Field) {
|
Field != FieldEnd; ++Field) {
|
||||||
FieldRegion* FR = MRMgr.getFieldRegion(*Field, R);
|
FieldRegion* FR = MRMgr.getFieldRegion(*Field, R);
|
||||||
QualType FTy = (*Field)->getType();
|
QualType FTy = (*Field)->getType();
|
||||||
SVal FieldValue = Retrieve(state, loc::MemRegionVal(FR), FTy).getSVal();
|
SVal FieldValue = Retrieve(store, loc::MemRegionVal(FR), FTy).getSVal();
|
||||||
StructVal = getBasicVals().consVals(FieldValue, StructVal);
|
StructVal = getBasicVals().consVals(FieldValue, StructVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ValMgr.makeCompoundVal(T, StructVal);
|
return ValMgr.makeCompoundVal(T, StructVal);
|
||||||
#else
|
#else
|
||||||
return ValMgr.makeLazyCompoundVal(state->getStore(), R);
|
return ValMgr.makeLazyCompoundVal(store, R);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SVal RegionStoreManager::RetrieveArray(const GRState *state,
|
SVal RegionStoreManager::RetrieveArray(Store store, const TypedRegion * R) {
|
||||||
const TypedRegion * R) {
|
|
||||||
#if USE_EXPLICIT_COMPOUND
|
#if USE_EXPLICIT_COMPOUND
|
||||||
QualType T = R->getValueType(getContext());
|
QualType T = R->getValueType(getContext());
|
||||||
ConstantArrayType* CAT = cast<ConstantArrayType>(T.getTypePtr());
|
ConstantArrayType* CAT = cast<ConstantArrayType>(T.getTypePtr());
|
||||||
|
@ -1473,14 +1468,14 @@ SVal RegionStoreManager::RetrieveArray(const GRState *state,
|
||||||
ElementRegion* ER = MRMgr.getElementRegion(CAT->getElementType(), Idx, R,
|
ElementRegion* ER = MRMgr.getElementRegion(CAT->getElementType(), Idx, R,
|
||||||
getContext());
|
getContext());
|
||||||
QualType ETy = ER->getElementType();
|
QualType ETy = ER->getElementType();
|
||||||
SVal ElementVal = Retrieve(state, loc::MemRegionVal(ER), ETy).getSVal();
|
SVal ElementVal = Retrieve(store, loc::MemRegionVal(ER), ETy).getSVal();
|
||||||
ArrayVal = getBasicVals().consVals(ElementVal, ArrayVal);
|
ArrayVal = getBasicVals().consVals(ElementVal, ArrayVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ValMgr.makeCompoundVal(T, ArrayVal);
|
return ValMgr.makeCompoundVal(T, ArrayVal);
|
||||||
#else
|
#else
|
||||||
assert(isa<ConstantArrayType>(R->getValueType(getContext())));
|
assert(isa<ConstantArrayType>(R->getValueType(getContext())));
|
||||||
return ValMgr.makeLazyCompoundVal(state->getStore(), R);
|
return ValMgr.makeLazyCompoundVal(store, R);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче