diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Checker/BasicStore.cpp | 48 | ||||
-rw-r--r-- | clang/lib/Checker/FlatStore.cpp | 19 | ||||
-rw-r--r-- | clang/lib/Checker/RegionStore.cpp | 55 | ||||
-rw-r--r-- | clang/lib/Checker/Store.cpp | 36 |
4 files changed, 36 insertions, 122 deletions
diff --git a/clang/lib/Checker/BasicStore.cpp b/clang/lib/Checker/BasicStore.cpp index 8d52bf53bea..de9643e91e3 100644 --- a/clang/lib/Checker/BasicStore.cpp +++ b/clang/lib/Checker/BasicStore.cpp @@ -70,8 +70,6 @@ public: return store; } - SVal getLValueIvar(const ObjCIvarDecl* D, SVal Base); - SVal getLValueField(const FieldDecl *D, SVal Base); SVal getLValueElement(QualType elementType, SVal Offset, SVal Base); /// ArrayToPointer - Used by GRExprEngine::VistCast to handle implicit @@ -113,52 +111,6 @@ StoreManager* clang::CreateBasicStoreManager(GRStateManager& StMgr) { return new BasicStoreManager(StMgr); } -SVal BasicStoreManager::getLValueIvar(const ObjCIvarDecl* D, SVal Base) { - - if (Base.isUnknownOrUndef()) - return Base; - - Loc BaseL = cast<Loc>(Base); - - if (isa<loc::MemRegionVal>(BaseL)) { - const MemRegion *BaseR = cast<loc::MemRegionVal>(BaseL).getRegion(); - return ValMgr.makeLoc(MRMgr.getObjCIvarRegion(D, BaseR)); - } - - return UnknownVal(); -} - -SVal BasicStoreManager::getLValueField(const FieldDecl* D, SVal Base) { - - if (Base.isUnknownOrUndef()) - return Base; - - Loc BaseL = cast<Loc>(Base); - const MemRegion* BaseR = 0; - - switch(BaseL.getSubKind()) { - case loc::GotoLabelKind: - return UndefinedVal(); - - case loc::MemRegionKind: - BaseR = cast<loc::MemRegionVal>(BaseL).getRegion(); - break; - - case loc::ConcreteIntKind: - // While these seem funny, this can happen through casts. - // FIXME: What we should return is the field offset. For example, - // add the field offset to the integer value. That way funny things - // like this work properly: &(((struct foo *) 0xa)->f) - return Base; - - default: - assert ("Unhandled Base."); - return Base; - } - - return ValMgr.makeLoc(MRMgr.getFieldRegion(D, BaseR)); -} - SVal BasicStoreManager::getLValueElement(QualType elementType, SVal Offset, SVal Base) { diff --git a/clang/lib/Checker/FlatStore.cpp b/clang/lib/Checker/FlatStore.cpp index fdeeab95293..f427ae1cecc 100644 --- a/clang/lib/Checker/FlatStore.cpp +++ b/clang/lib/Checker/FlatStore.cpp @@ -42,13 +42,6 @@ public: return 0; } - SVal getLValueVar(const VarDecl *VD, const LocationContext *LC) { - return loc::MemRegionVal(MRMgr.getVarRegion(VD, LC)); - } - - SVal getLValueString(const StringLiteral* sl); - SVal getLValueIvar(const ObjCIvarDecl* decl, SVal base); - SVal getLValueField(const FieldDecl* D, SVal Base); SVal getLValueElement(QualType elementType, SVal offset, SVal Base); SVal ArrayToPointer(Loc Array); Store RemoveDeadBindings(Store store, Stmt* Loc, SymbolReaper& SymReaper, @@ -133,18 +126,6 @@ Store FlatStoreManager::BindCompoundLiteral(Store store, return store; } -SVal FlatStoreManager::getLValueString(const StringLiteral* sl) { - return UnknownVal(); -} - -SVal FlatStoreManager::getLValueIvar(const ObjCIvarDecl* decl, SVal base) { - return UnknownVal(); -} - -SVal FlatStoreManager::getLValueField(const FieldDecl* D, SVal Base) { - return UnknownVal(); -} - SVal FlatStoreManager::getLValueElement(QualType elementType, SVal offset, SVal Base) { return UnknownVal(); diff --git a/clang/lib/Checker/RegionStore.cpp b/clang/lib/Checker/RegionStore.cpp index 139ef6a7e21..1917e53e824 100644 --- a/clang/lib/Checker/RegionStore.cpp +++ b/clang/lib/Checker/RegionStore.cpp @@ -232,12 +232,6 @@ public: /// the value is not specified. Store setImplicitDefaultValue(Store store, const MemRegion *R, QualType T); - SVal getLValueIvar(const ObjCIvarDecl* D, SVal Base); - - SVal getLValueField(const FieldDecl* D, SVal Base); - - SVal getLValueFieldOrIvar(const Decl* D, SVal Base); - SVal getLValueElement(QualType elementType, SVal Offset, SVal Base); @@ -658,55 +652,6 @@ Store RegionStoreManager::InvalidateRegions(Store store, StateMgr.getValueManager()); } - -//===----------------------------------------------------------------------===// -// getLValueXXX methods. -//===----------------------------------------------------------------------===// - -SVal RegionStoreManager::getLValueIvar(const ObjCIvarDecl* D, SVal Base) { - return getLValueFieldOrIvar(D, Base); -} - -SVal RegionStoreManager::getLValueField(const FieldDecl* D, SVal Base) { - return getLValueFieldOrIvar(D, Base); -} - -SVal RegionStoreManager::getLValueFieldOrIvar(const Decl* D, SVal Base) { - if (Base.isUnknownOrUndef()) - return Base; - - Loc BaseL = cast<Loc>(Base); - const MemRegion* BaseR = 0; - - switch (BaseL.getSubKind()) { - case loc::MemRegionKind: - BaseR = cast<loc::MemRegionVal>(BaseL).getRegion(); - break; - - case loc::GotoLabelKind: - // These are anormal cases. Flag an undefined value. - return UndefinedVal(); - - case loc::ConcreteIntKind: - // While these seem funny, this can happen through casts. - // FIXME: What we should return is the field offset. For example, - // add the field offset to the integer value. That way funny things - // like this work properly: &(((struct foo *) 0xa)->f) - return Base; - - default: - assert(0 && "Unhandled Base."); - return Base; - } - - // NOTE: We must have this check first because ObjCIvarDecl is a subclass - // of FieldDecl. - if (const ObjCIvarDecl *ID = dyn_cast<ObjCIvarDecl>(D)) - return loc::MemRegionVal(MRMgr.getObjCIvarRegion(ID, BaseR)); - - return loc::MemRegionVal(MRMgr.getFieldRegion(cast<FieldDecl>(D), BaseR)); -} - SVal RegionStoreManager::getLValueElement(QualType elementType, SVal Offset, SVal Base) { diff --git a/clang/lib/Checker/Store.cpp b/clang/lib/Checker/Store.cpp index 5a8f8853324..7190bdabb6b 100644 --- a/clang/lib/Checker/Store.cpp +++ b/clang/lib/Checker/Store.cpp @@ -234,3 +234,39 @@ Store StoreManager::InvalidateRegions(Store store, return store; } + +SVal StoreManager::getLValueFieldOrIvar(const Decl* D, SVal Base) { + if (Base.isUnknownOrUndef()) + return Base; + + Loc BaseL = cast<Loc>(Base); + const MemRegion* BaseR = 0; + + switch (BaseL.getSubKind()) { + case loc::MemRegionKind: + BaseR = cast<loc::MemRegionVal>(BaseL).getRegion(); + break; + + case loc::GotoLabelKind: + // These are anormal cases. Flag an undefined value. + return UndefinedVal(); + + case loc::ConcreteIntKind: + // While these seem funny, this can happen through casts. + // FIXME: What we should return is the field offset. For example, + // add the field offset to the integer value. That way funny things + // like this work properly: &(((struct foo *) 0xa)->f) + return Base; + + default: + assert(0 && "Unhandled Base."); + return Base; + } + + // NOTE: We must have this check first because ObjCIvarDecl is a subclass + // of FieldDecl. + if (const ObjCIvarDecl *ID = dyn_cast<ObjCIvarDecl>(D)) + return loc::MemRegionVal(MRMgr.getObjCIvarRegion(ID, BaseR)); + + return loc::MemRegionVal(MRMgr.getFieldRegion(cast<FieldDecl>(D), BaseR)); +} |