From: Ted Kremenek Date: Sun, 2 Aug 2009 05:15:23 +0000 (+0000) Subject: Remove RegionViews and RegionCasts. These are no longer used. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=df74e25bf0d82339a28e8a4c5e9413584771363b;p=clang Remove RegionViews and RegionCasts. These are no longer used. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77876 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Analysis/PathSensitive/Store.h b/include/clang/Analysis/PathSensitive/Store.h index 2d79a19b44..fcc5e54cf7 100644 --- a/include/clang/Analysis/PathSensitive/Store.h +++ b/include/clang/Analysis/PathSensitive/Store.h @@ -43,13 +43,6 @@ protected: StoreManager(GRStateManager &stateMgr); -protected: - virtual const GRState *AddRegionView(const GRState *state, - const MemRegion *view, - const MemRegion *base) { - return state; - } - public: virtual ~StoreManager() {} @@ -134,16 +127,7 @@ public: /// a MemRegion* to a specific location type. 'R' is the region being /// casted and 'CastToTy' the result type of the cast. CastResult CastRegion(const GRState *state, const MemRegion *region, - QualType CastToTy); - - virtual const GRState *setCastType(const GRState *state, const MemRegion* R, - QualType T) { - return state; - } - - virtual const QualType *getCastType(const GRState *state, const MemRegion *R){ - return 0; - } + QualType CastToTy); /// EvalBinOp - Perform pointer arithmetic. virtual SVal EvalBinOp(const GRState *state, BinaryOperator::Opcode Op, diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp index 32a1dc0175..543783d924 100644 --- a/lib/Analysis/RegionStore.cpp +++ b/lib/Analysis/RegionStore.cpp @@ -27,7 +27,6 @@ using namespace clang; -#define USE_REGION_CASTS 0 #define HEAP_UNDEFINED 0 // Actual Store type. @@ -59,36 +58,6 @@ public: }; } -//===----------------------------------------------------------------------===// -// Region "Views" -//===----------------------------------------------------------------------===// -// -// MemRegions can be layered on top of each other. This GDM entry tracks -// what are the MemRegions that layer a given MemRegion. -// -typedef llvm::ImmutableSet RegionViews; -namespace { class VISIBILITY_HIDDEN RegionViewMap {}; } -static int RegionViewMapIndex = 0; -namespace clang { - template<> struct GRStateTrait - : public GRStatePartialTrait > { - - static void* GDMIndex() { return &RegionViewMapIndex; } - }; -} - -// RegionCasts records the current cast type of a region. -namespace { class VISIBILITY_HIDDEN RegionCasts {}; } -static int RegionCastsIndex = 0; -namespace clang { - template<> struct GRStateTrait - : public GRStatePartialTrait > { - static void* GDMIndex() { return &RegionCastsIndex; } - }; -} - //===----------------------------------------------------------------------===// // Region "Extents" //===----------------------------------------------------------------------===// @@ -186,7 +155,6 @@ public: class VISIBILITY_HIDDEN RegionStoreManager : public StoreManager { const RegionStoreFeatures Features; RegionBindingsTy::Factory RBFactory; - RegionViews::Factory RVFactory; const MemRegion* SelfRegion; const ImplicitParamDecl *SelfDecl; @@ -196,7 +164,6 @@ public: : StoreManager(mgr), Features(f), RBFactory(mgr.getAllocator()), - RVFactory(mgr.getAllocator()), SelfRegion(0), SelfDecl(0) { if (const ObjCMethodDecl* MD = dyn_cast(&StateMgr.getCodeDecl())) @@ -371,13 +338,6 @@ public: // Utility methods. //===------------------------------------------------------------------===// - const GRState *setCastType(const GRState *state, const MemRegion* R, - QualType T); - - const QualType *getCastType(const GRState *state, const MemRegion *R) { - return state->get(R); - } - static inline RegionBindingsTy GetRegionBindings(Store store) { return RegionBindingsTy(static_cast(store)); } @@ -400,27 +360,6 @@ public: } // end anonymous namespace -static bool isGenericPtr(ASTContext &Ctx, QualType Ty) { - if (Ty->isObjCIdType() || Ty->isObjCQualifiedIdType()) - return true; - - while (true) { - Ty = Ctx.getCanonicalType(Ty); - - if (Ty->isVoidType()) - return true; - - if (const PointerType *PT = Ty->getAs()) { - Ty = PT->getPointeeType(); - continue; - } - - break; - } - - return false; -} - //===----------------------------------------------------------------------===// // RegionStore creation. //===----------------------------------------------------------------------===// @@ -751,20 +690,7 @@ SVal RegionStoreManager::getSizeInElements(const GRState *state, // return the size as signed integer. return ValMgr.makeIntVal(CAT->getSize(), false); } - - const QualType* CastTy = state->get(VR); - - // If the VarRegion is cast to other type, compute the size with respect to - // that type. - if (CastTy) { - QualType EleTy =cast(CastTy->getTypePtr())->getPointeeType(); - QualType VarTy = VR->getValueType(getContext()); - uint64_t EleSize = getContext().getTypeSize(EleTy); - uint64_t VarSize = getContext().getTypeSize(VarTy); - assert(VarSize != 0); - return ValMgr.makeIntVal(VarSize/EleSize, false); - } - + // Clients can use ordinary variables as if they were arrays. These // essentially are arrays of size 1. return ValMgr.makeIntVal(1, false); @@ -836,28 +762,16 @@ SVal RegionStoreManager::EvalBinOp(const GRState *state, switch (MR->getKind()) { case MemRegion::SymbolicRegionKind: { const SymbolicRegion *SR = cast(MR); - QualType T; -#if USE_REGION_CASTS - // If the SymbolicRegion was cast to another type, use that type. - if (const QualType *t = state->get(SR)) - T = *t; - else -#endif - { - // Otherwise use the symbol's type. - SymbolRef Sym = SR->getSymbol(); - T = Sym->getType(getContext()); - } - + SymbolRef Sym = SR->getSymbol(); + QualType T = Sym->getType(getContext()); QualType EleTy = T->getAs()->getPointeeType(); SVal ZeroIdx = ValMgr.makeZeroArrayIndex(); ER = MRMgr.getElementRegion(EleTy, ZeroIdx, SR, getContext()); break; } case MemRegion::AllocaRegionKind: { - // Get the alloca region's current cast type. const AllocaRegion *AR = cast(MR); - QualType T = *(state->get(AR)); + QualType T = getContext().CharTy; // Create an ElementRegion of bytes. QualType EleTy = T->getAs()->getPointeeType(); SVal ZeroIdx = ValMgr.makeZeroArrayIndex(); ER = MRMgr.getElementRegion(EleTy, ZeroIdx, AR, getContext()); @@ -1551,51 +1465,6 @@ const GRState *RegionStoreManager::KillStruct(const GRState *state, return state->makeWithStore(store); } -//===----------------------------------------------------------------------===// -// Region views. -//===----------------------------------------------------------------------===// - -const GRState *RegionStoreManager::AddRegionView(const GRState *state, - const MemRegion* View, - const MemRegion* Base) { - - // First, retrieve the region view of the base region. - const RegionViews* d = state->get(Base); - RegionViews L = d ? *d : RVFactory.GetEmptySet(); - - // Now add View to the region view. - L = RVFactory.Add(L, View); - - // Create a new state with the new region view. - return state->set(Base, L); -} - -const GRState *RegionStoreManager::RemoveRegionView(const GRState *state, - const MemRegion* View, - const MemRegion* Base) { - // Retrieve the region view of the base region. - const RegionViews* d = state->get(Base); - - // If the base region has no view, return. - if (!d) - return state; - - // Remove the view. - return state->set(Base, RVFactory.Remove(*d, View)); -} - -const GRState *RegionStoreManager::setCastType(const GRState *state, - const MemRegion* R, QualType T) { - // We do not record generic cast type, since we are using cast type to - // invlidate regions, and generic type is meaningless for invalidating - // regions. - // If the region already has a cast type before, that type is preserved. - // FIXME: is this the right thing to do? - if (isGenericPtr(getContext(), T)) - return state; - return state->set(R, T); -} - const GRState *RegionStoreManager::setDefaultValue(const GRState *state, const MemRegion* R, SVal V) { return state->set(R, V);