diff options
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Analysis/BasicStore.cpp | 10 | ||||
-rw-r--r-- | clang/lib/Analysis/MemRegion.cpp | 27 | ||||
-rw-r--r-- | clang/lib/Analysis/RegionStore.cpp | 10 | ||||
-rw-r--r-- | clang/lib/Analysis/SVals.cpp | 17 | ||||
-rw-r--r-- | clang/lib/Analysis/SValuator.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Analysis/Store.cpp | 100 |
6 files changed, 11 insertions, 157 deletions
diff --git a/clang/lib/Analysis/BasicStore.cpp b/clang/lib/Analysis/BasicStore.cpp index b84bdf41005..a898147102f 100644 --- a/clang/lib/Analysis/BasicStore.cpp +++ b/clang/lib/Analysis/BasicStore.cpp @@ -38,10 +38,8 @@ class VISIBILITY_HIDDEN BasicStoreManager : public StoreManager { const MemRegion* SelfRegion; public: - BasicStoreManager(GRStateManager& mgr, bool useNewCastRegion = true) - : StoreManager(mgr, useNewCastRegion), - VBFactory(mgr.getAllocator()), - SelfRegion(0) {} + BasicStoreManager(GRStateManager& mgr) + : StoreManager(mgr), VBFactory(mgr.getAllocator()), SelfRegion(0) {} ~BasicStoreManager() {} @@ -130,10 +128,6 @@ StoreManager* clang::CreateBasicStoreManager(GRStateManager& StMgr) { return new BasicStoreManager(StMgr); } -StoreManager* clang::CreateBasicStoreOldCastManager(GRStateManager& StMgr) { - return new BasicStoreManager(StMgr, false); -} - SVal BasicStoreManager::getLValueVar(const GRState *state, const VarDecl* VD) { return ValMgr.makeLoc(MRMgr.getVarRegion(VD)); } diff --git a/clang/lib/Analysis/MemRegion.cpp b/clang/lib/Analysis/MemRegion.cpp index a708bd3068f..3c174df2820 100644 --- a/clang/lib/Analysis/MemRegion.cpp +++ b/clang/lib/Analysis/MemRegion.cpp @@ -74,13 +74,6 @@ void AllocaRegion::Profile(llvm::FoldingSetNodeID& ID) const { ProfileRegion(ID, Ex, Cnt, superRegion); } -void TypedViewRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, QualType T, - const MemRegion* superRegion) { - ID.AddInteger((unsigned) TypedViewRegionKind); - ID.Add(T); - ID.AddPointer(superRegion); -} - void CompoundLiteralRegion::Profile(llvm::FoldingSetNodeID& ID) const { CompoundLiteralRegion::ProfileRegion(ID, CL, superRegion); } @@ -197,11 +190,6 @@ void SymbolicRegion::dumpToStream(llvm::raw_ostream& os) const { os << "SymRegion{" << sym << '}'; } -void TypedViewRegion::dumpToStream(llvm::raw_ostream& os) const { - os << "typed_view{" << LValueType.getAsString() << ',' - << getSuperRegion() << '}'; -} - void VarRegion::dumpToStream(llvm::raw_ostream& os) const { os << cast<VarDecl>(D)->getNameAsString(); } @@ -314,11 +302,6 @@ MemRegionManager::getObjCObjectRegion(const ObjCInterfaceDecl* d, return getSubRegion<ObjCObjectRegion>(d, superRegion); } -TypedViewRegion* -MemRegionManager::getTypedViewRegion(QualType t, const MemRegion* superRegion) { - return getSubRegion<TypedViewRegion>(t, superRegion); -} - AllocaRegion* MemRegionManager::getAllocaRegion(const Expr* E, unsigned cnt) { return getRegion<AllocaRegion>(E, cnt); } @@ -389,16 +372,6 @@ bool MemRegion::hasGlobalsOrParametersStorage() const { // View handling. //===----------------------------------------------------------------------===// -const MemRegion *TypedViewRegion::removeViews() const { - const SubRegion *SR = this; - const MemRegion *R = SR; - while (SR && isa<TypedViewRegion>(SR)) { - R = SR->getSuperRegion(); - SR = dyn_cast<SubRegion>(R); - } - return R; -} - const MemRegion *MemRegion::getBaseRegion() const { const MemRegion *R = this; while (true) { diff --git a/clang/lib/Analysis/RegionStore.cpp b/clang/lib/Analysis/RegionStore.cpp index c533a7ec074..ccfbb27ccf2 100644 --- a/clang/lib/Analysis/RegionStore.cpp +++ b/clang/lib/Analysis/RegionStore.cpp @@ -170,7 +170,7 @@ class VISIBILITY_HIDDEN RegionStoreManager : public StoreManager { public: RegionStoreManager(GRStateManager& mgr, const RegionStoreFeatures &f) - : StoreManager(mgr, true), + : StoreManager(mgr), Features(f), RBFactory(mgr.getAllocator()), RVFactory(mgr.getAllocator()), @@ -679,10 +679,6 @@ SVal RegionStoreManager::getSizeInElements(const GRState *state, return ValMgr.makeIntVal(Str->getByteLength()+1, false); } - // TypedViewRegion will soon be removed. - case MemRegion::TypedViewRegionKind: - return UnknownVal(); - case MemRegion::VarRegionKind: { const VarRegion* VR = cast<VarRegion>(R); // Get the type of the variable. @@ -823,10 +819,6 @@ SVal RegionStoreManager::EvalBinOp(const GRState *state, case MemRegion::ObjCIvarRegionKind: return UnknownVal(); - // TypedViewRegion will soon be removed. - case MemRegion::TypedViewRegionKind: - return UnknownVal(); - case MemRegion::CodeTextRegionKind: // Technically this can happen if people do funny things with casts. return UnknownVal(); diff --git a/clang/lib/Analysis/SVals.cpp b/clang/lib/Analysis/SVals.cpp index 6f480e8d46b..5ac18a15065 100644 --- a/clang/lib/Analysis/SVals.cpp +++ b/clang/lib/Analysis/SVals.cpp @@ -73,21 +73,10 @@ const FunctionDecl* SVal::getAsFunctionDecl() const { SymbolRef SVal::getAsLocSymbol() const { if (const loc::MemRegionVal *X = dyn_cast<loc::MemRegionVal>(this)) { const MemRegion *R = X->getBaseRegion(); - - while (R) { - // Blast through region views. - if (const TypedViewRegion *View = dyn_cast<TypedViewRegion>(R)) { - R = View->getSuperRegion(); - continue; - } - if (const SymbolicRegion *SymR = dyn_cast<SymbolicRegion>(R)) - return SymR->getSymbol(); - - break; - } + if (const SymbolicRegion *SymR = dyn_cast<SymbolicRegion>(R)) + return SymR->getSymbol(); } - - return 0; + return NULL; } /// getAsSymbol - If this Sval wraps a symbol return that SymbolRef. diff --git a/clang/lib/Analysis/SValuator.cpp b/clang/lib/Analysis/SValuator.cpp index 787c926f6ba..079481a62ac 100644 --- a/clang/lib/Analysis/SValuator.cpp +++ b/clang/lib/Analysis/SValuator.cpp @@ -73,10 +73,6 @@ SValuator::CastResult SValuator::EvalCast(SVal val, const GRState *state, // Check for casts from a region to a specific type. if (const MemRegion *R = val.getAsRegion()) { - // FIXME: For TypedViewRegions, we should handle the case where the - // underlying symbolic pointer is a function pointer or - // block pointer. - // FIXME: We should handle the case where we strip off view layers to get // to a desugared type. diff --git a/clang/lib/Analysis/Store.cpp b/clang/lib/Analysis/Store.cpp index 114942177cc..4341abdc725 100644 --- a/clang/lib/Analysis/Store.cpp +++ b/clang/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); -} |