[cfe-commits] r95535 - in /cfe/trunk: include/clang/Checker/PathSensitive/Store.h lib/Checker/BasicStore.cpp lib/Checker/FlatStore.cpp lib/Checker/RegionStore.cpp lib/Checker/Store.cpp
Ted Kremenek
kremenek at apple.com
Mon Feb 8 08:29:37 PST 2010
Now that the MemRegion model has converged, this makes a lot of sense. Should we make these methods non-virtual?
On Feb 7, 2010, at 11:58 PM, Zhongxing Xu wrote:
> Author: zhongxingxu
> Date: Mon Feb 8 01:58:06 2010
> New Revision: 95535
>
> URL: http://llvm.org/viewvc/llvm-project?rev=95535&view=rev
> Log:
> Unify the implementation of getLValueIvar and getLValueField of store managers.
>
> Modified:
> cfe/trunk/include/clang/Checker/PathSensitive/Store.h
> cfe/trunk/lib/Checker/BasicStore.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/Store.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/Store.h?rev=95535&r1=95534&r2=95535&view=diff
>
> ==============================================================================
> --- cfe/trunk/include/clang/Checker/PathSensitive/Store.h (original)
> +++ cfe/trunk/include/clang/Checker/PathSensitive/Store.h Mon Feb 8 01:58:06 2010
> @@ -102,9 +102,13 @@
> return loc::MemRegionVal(MRMgr.getCompoundLiteralRegion(CL, LC));
> }
>
> - virtual SVal getLValueIvar(const ObjCIvarDecl* decl, SVal base) = 0;
> + virtual SVal getLValueIvar(const ObjCIvarDecl* decl, SVal base) {
> + return getLValueFieldOrIvar(decl, base);
> + }
>
> - virtual SVal getLValueField(const FieldDecl* D, SVal Base) = 0;
> + virtual SVal getLValueField(const FieldDecl* D, SVal Base) {
> + return getLValueFieldOrIvar(D, Base);
> + }
>
> virtual SVal getLValueElement(QualType elementType, SVal offset, SVal Base)=0;
>
> @@ -195,6 +199,9 @@
> /// as another region.
> SVal CastRetrievedVal(SVal val, const TypedRegion *R, QualType castTy,
> bool performTestOnly = true);
> +
> +private:
> + SVal getLValueFieldOrIvar(const Decl* D, SVal Base);
> };
>
> // FIXME: Do we still need this?
>
> Modified: cfe/trunk/lib/Checker/BasicStore.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/BasicStore.cpp?rev=95535&r1=95534&r2=95535&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Checker/BasicStore.cpp (original)
> +++ cfe/trunk/lib/Checker/BasicStore.cpp Mon Feb 8 01:58:06 2010
> @@ -70,8 +70,6 @@
> 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 @@
> 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) {
>
>
> Modified: cfe/trunk/lib/Checker/FlatStore.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/FlatStore.cpp?rev=95535&r1=95534&r2=95535&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Checker/FlatStore.cpp (original)
> +++ cfe/trunk/lib/Checker/FlatStore.cpp Mon Feb 8 01:58:06 2010
> @@ -42,13 +42,6 @@
> 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 @@
> 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();
>
> Modified: cfe/trunk/lib/Checker/RegionStore.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/RegionStore.cpp?rev=95535&r1=95534&r2=95535&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Checker/RegionStore.cpp (original)
> +++ cfe/trunk/lib/Checker/RegionStore.cpp Mon Feb 8 01:58:06 2010
> @@ -232,12 +232,6 @@
> /// 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 @@
> 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) {
>
>
> Modified: cfe/trunk/lib/Checker/Store.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/Store.cpp?rev=95535&r1=95534&r2=95535&view=diff
>
> ==============================================================================
> --- cfe/trunk/lib/Checker/Store.cpp (original)
> +++ cfe/trunk/lib/Checker/Store.cpp Mon Feb 8 01:58:06 2010
> @@ -234,3 +234,39 @@
>
> 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));
> +}
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list