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
diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp
index b84bdf4..a898147 100644
--- a/lib/Analysis/BasicStore.cpp
+++ b/lib/Analysis/BasicStore.cpp
@@ -38,10 +38,8 @@
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 @@
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/lib/Analysis/MemRegion.cpp b/lib/Analysis/MemRegion.cpp
index a708bd3..3c174df 100644
--- a/lib/Analysis/MemRegion.cpp
+++ b/lib/Analysis/MemRegion.cpp
@@ -74,13 +74,6 @@
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 @@
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 @@
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 @@
// 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/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp
index c533a7e..ccfbb27 100644
--- a/lib/Analysis/RegionStore.cpp
+++ b/lib/Analysis/RegionStore.cpp
@@ -170,7 +170,7 @@
public:
RegionStoreManager(GRStateManager& mgr, const RegionStoreFeatures &f)
- : StoreManager(mgr, true),
+ : StoreManager(mgr),
Features(f),
RBFactory(mgr.getAllocator()),
RVFactory(mgr.getAllocator()),
@@ -679,10 +679,6 @@
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 @@
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/lib/Analysis/SVals.cpp b/lib/Analysis/SVals.cpp
index 6f480e8..5ac18a1 100644
--- a/lib/Analysis/SVals.cpp
+++ b/lib/Analysis/SVals.cpp
@@ -73,21 +73,10 @@
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/lib/Analysis/SValuator.cpp b/lib/Analysis/SValuator.cpp
index 787c926..079481a 100644
--- a/lib/Analysis/SValuator.cpp
+++ b/lib/Analysis/SValuator.cpp
@@ -73,10 +73,6 @@
// 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/lib/Analysis/Store.cpp b/lib/Analysis/Store.cpp
index 1149421..4341abd 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 @@
}
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 @@
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 @@
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);
-}