- Remove AnonTypedRegion, which is not to be used.

- Prepare AnonPointeeRegioin for later use.

llvm-svn: 58595
This commit is contained in:
Zhongxing Xu 2008-11-03 04:12:24 +00:00
parent 7874fe900a
commit 2d330ef8fa
2 changed files with 29 additions and 53 deletions

View File

@ -47,7 +47,7 @@ public:
VarRegionKind, FieldRegionKind,
ObjCIvarRegionKind, ObjCObjectRegionKind,
END_DECL_REGIONS,
AnonTypedRegionKind, AnonPointeeRegionKind,
AnonPointeeRegionKind,
END_TYPED_REGIONS };
private:
const Kind kind;
@ -199,53 +199,35 @@ public:
}
};
/// AnonTypedRegion - An "anonymous" region that simply types a chunk
/// of memory.
class AnonTypedRegion : public TypedRegion {
protected:
QualType T;
/// AnonPointeeRegion - anonymous regions pointed-to by pointer function
/// parameters or pointer globals. In RegionStoreManager, we assume pointer
/// parameters or globals point at some anonymous region. Such regions are not
/// the regions associated with the pointer variables themselves. They are
/// identified with the VarDecl of the pointer variable. We create them lazily.
class AnonPointeeRegion : public TypedRegion {
friend class MemRegionManager;
AnonTypedRegion(QualType t, MemRegion* sreg)
: TypedRegion(sreg, AnonTypedRegionKind), T(t) {}
// VD - the pointer variable that points at this region.
const VarDecl* Pointer;
static void ProfileRegion(llvm::FoldingSetNodeID& ID, QualType T,
const MemRegion* superRegion);
AnonPointeeRegion(const VarDecl* d, MemRegion* sreg)
: TypedRegion(sreg, AnonPointeeRegionKind), Pointer(d) {}
public:
QualType getType(ASTContext& C) const { return C.getCanonicalType(T); }
QualType getType(ASTContext& C) const;
static void ProfileRegion(llvm::FoldingSetNodeID& ID, const VarDecl* PVD,
const MemRegion* superRegion);
void Profile(llvm::FoldingSetNodeID& ID) const {
ProfileRegion(ID, Pointer, superRegion);
}
void Profile(llvm::FoldingSetNodeID& ID) const;
static bool classof(const MemRegion* R) {
return R->getKind() == AnonTypedRegionKind;
return R->getKind() == AnonPointeeRegionKind;
}
};
/// AnonPointeeRegion - anonymous regions pointed-at by pointer function
/// parameters or pointer globals. In RegionStoreManager, we assume pointer
/// parameters or globals point at some anonymous region initially. Such
/// regions are not the regions associated with the pointers themselves, but
/// are identified with the VarDecl of the parameters or globals.
class AnonPointeeRegion : public AnonTypedRegion {
friend class MemRegionManager;
// VD - the pointer variable that points at this region.
const VarDecl* VD;
AnonPointeeRegion(const VarDecl* d, QualType t, MemRegion* sreg)
: AnonTypedRegion(t, sreg), VD(d) {}
public:
static void ProfileRegion(llvm::FoldingSetNodeID& ID, const VarDecl* PVD,
QualType T, const MemRegion* superRegion);
};
/// AnonHeapRegion - anonymous region created by malloc().
class AnonHeapRegion : public AnonTypedRegion {
};
/// CompoundLiteralRegion - A memory region representing a compound literal.
/// Compound literals are essentially temporaries that are stack allocated
/// or in the global constant pool.

View File

@ -44,26 +44,22 @@ void AllocaRegion::Profile(llvm::FoldingSetNodeID& ID) const {
ProfileRegion(ID, Ex, Cnt);
}
void AnonTypedRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, QualType T,
const MemRegion* superRegion) {
ID.AddInteger((unsigned) AnonTypedRegionKind);
ID.Add(T);
ID.AddPointer(superRegion);
QualType AnonPointeeRegion::getType(ASTContext& C) const {
QualType T = C.getCanonicalType(Pointer->getType());
PointerType* PTy = cast<PointerType>(T.getTypePtr());
QualType PointeeTy = C.getCanonicalType(PTy->getPointeeType());
return PointeeTy;
}
void AnonPointeeRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
const VarDecl* VD, QualType T,
const VarDecl* VD,
const MemRegion* superRegion) {
ID.AddInteger((unsigned) AnonPointeeRegionKind);
ID.Add(T);
ID.AddPointer(VD);
ID.AddPointer(superRegion);
}
void AnonTypedRegion::Profile(llvm::FoldingSetNodeID& ID) const {
AnonTypedRegion::ProfileRegion(ID, T, superRegion);
}
void CompoundLiteralRegion::Profile(llvm::FoldingSetNodeID& ID) const {
CompoundLiteralRegion::ProfileRegion(ID, CL, superRegion);
}
@ -346,11 +342,9 @@ MemRegionManager::getObjCObjectRegion(const ObjCInterfaceDecl* d,
AnonPointeeRegion* MemRegionManager::getAnonPointeeRegion(const VarDecl* d) {
llvm::FoldingSetNodeID ID;
QualType T = d->getType();
QualType PointeeType = cast<PointerType>(T.getTypePtr())->getPointeeType();
MemRegion* superRegion = getUnknownRegion();
AnonPointeeRegion::ProfileRegion(ID, d, PointeeType, superRegion);
AnonPointeeRegion::ProfileRegion(ID, d, superRegion);
void* InsertPos;
MemRegion* data = Regions.FindNodeOrInsertPos(ID, InsertPos);
@ -358,7 +352,7 @@ AnonPointeeRegion* MemRegionManager::getAnonPointeeRegion(const VarDecl* d) {
if (!R) {
R = (AnonPointeeRegion*) A.Allocate<AnonPointeeRegion>();
new (R) AnonPointeeRegion(d, PointeeType, superRegion);
new (R) AnonPointeeRegion(d, superRegion);
Regions.InsertNode(R, InsertPos);
}