diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-07-29 21:43:22 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-07-29 21:43:22 +0000 |
commit | f7a0cf426eddae76e1a71dd2295631a2cf0560af (patch) | |
tree | da740e164bd7a40f49e72712c45867909f4962a1 /lib/Analysis/Store.cpp | |
parent | b7b6c4c6c72f817df4485329221b4de721a62340 (diff) |
Remove 'StoreManager::OldCastRegion()', TypedViewRegion (which only
OldCastRegion used), and the associated command line option
'-analyzer-store=old-basic-cast'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77509 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/Store.cpp')
-rw-r--r-- | lib/Analysis/Store.cpp | 100 |
1 files changed, 5 insertions, 95 deletions
diff --git a/lib/Analysis/Store.cpp b/lib/Analysis/Store.cpp index 114942177c..4341abdc72 100644 --- a/lib/Analysis/Store.cpp +++ b/lib/Analysis/Store.cpp @@ -16,10 +16,8 @@ using namespace clang; -StoreManager::StoreManager(GRStateManager &stateMgr, bool useNewCastRegion) - : ValMgr(stateMgr.getValueManager()), - StateMgr(stateMgr), - UseNewCastRegion(useNewCastRegion), +StoreManager::StoreManager(GRStateManager &stateMgr) + : ValMgr(stateMgr.getValueManager()), StateMgr(stateMgr), MRMgr(ValMgr.getRegionManager()) {} StoreManager::CastResult @@ -46,8 +44,8 @@ static bool IsCompleteType(ASTContext &Ctx, QualType Ty) { } StoreManager::CastResult -StoreManager::NewCastRegion(const GRState *state, const MemRegion* R, - QualType CastToTy) { +StoreManager::CastRegion(const GRState *state, const MemRegion* R, + QualType CastToTy) { ASTContext& Ctx = StateMgr.getContext(); @@ -87,8 +85,7 @@ StoreManager::NewCastRegion(const GRState *state, const MemRegion* R, case MemRegion::MemSpaceRegionKind: case MemRegion::BEG_DECL_REGIONS: case MemRegion::END_DECL_REGIONS: - case MemRegion::END_TYPED_REGIONS: - case MemRegion::TypedViewRegionKind: { + case MemRegion::END_TYPED_REGIONS: { assert(0 && "Invalid region cast"); break; } @@ -147,90 +144,3 @@ StoreManager::NewCastRegion(const GRState *state, const MemRegion* R, return CastResult(state, R); } - - -StoreManager::CastResult -StoreManager::OldCastRegion(const GRState* state, const MemRegion* R, - QualType CastToTy) { - - ASTContext& Ctx = StateMgr.getContext(); - - // We need to know the real type of CastToTy. - QualType ToTy = Ctx.getCanonicalType(CastToTy); - - // Return the same region if the region types are compatible. - if (const TypedRegion* TR = dyn_cast<TypedRegion>(R)) { - QualType Ta = Ctx.getCanonicalType(TR->getLocationType(Ctx)); - - if (Ta == ToTy) - return CastResult(state, R); - } - - if (const PointerType* PTy = dyn_cast<PointerType>(ToTy.getTypePtr())) { - // Check if we are casting to 'void*'. - // FIXME: Handle arbitrary upcasts. - QualType Pointee = PTy->getPointeeType(); - if (Pointee->isVoidType()) { - while (true) { - if (const TypedViewRegion *TR = dyn_cast<TypedViewRegion>(R)) { - // Casts to void* removes TypedViewRegion. This happens when: - // - // void foo(void*); - // ... - // void bar() { - // int x; - // foo(&x); - // } - // - R = TR->removeViews(); - continue; - } - else if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) { - // Casts to void* also removes ElementRegions. This happens when: - // - // void foo(void*); - // ... - // void bar() { - // int x; - // foo((char*)&x); - // } - // - R = ER->getSuperRegion(); - continue; - } - - break; - } - - return CastResult(state, R); - } - else if (Pointee->isIntegerType()) { - // FIXME: At some point, it stands to reason that this 'dyn_cast' should - // become a 'cast' and that 'R' will always be a TypedRegion. - if (const TypedRegion *TR = dyn_cast<TypedRegion>(R)) { - // Check if we are casting to a region with an integer type. We now - // the types aren't the same, so we construct an ElementRegion. - SVal Idx = ValMgr.makeZeroArrayIndex(); - - // If the super region is an element region, strip it away. - // FIXME: Is this the right thing to do in all cases? - const MemRegion *Base = isa<ElementRegion>(TR) ? TR->getSuperRegion() - : TR; - ElementRegion* ER = MRMgr.getElementRegion(Pointee, Idx, Base, - StateMgr.getContext()); - return CastResult(state, ER); - } - } - } - - // FIXME: Need to handle arbitrary downcasts. - // FIXME: Handle the case where a TypedViewRegion (layering a SymbolicRegion - // or an AllocaRegion is cast to another view, thus causing the memory - // to be re-used for a different purpose. - if (isa<SymbolicRegion>(R) || isa<AllocaRegion>(R)) { - const MemRegion* ViewR = MRMgr.getTypedViewRegion(CastToTy, R); - return CastResult(AddRegionView(state, ViewR, R), ViewR); - } - - return CastResult(state, R); -} |