forked from OSchip/llvm-project
- Remove AnonTypedRegion, which is not to be used.
- Prepare AnonPointeeRegioin for later use. llvm-svn: 58595
This commit is contained in:
parent
7874fe900a
commit
2d330ef8fa
|
@ -47,7 +47,7 @@ public:
|
||||||
VarRegionKind, FieldRegionKind,
|
VarRegionKind, FieldRegionKind,
|
||||||
ObjCIvarRegionKind, ObjCObjectRegionKind,
|
ObjCIvarRegionKind, ObjCObjectRegionKind,
|
||||||
END_DECL_REGIONS,
|
END_DECL_REGIONS,
|
||||||
AnonTypedRegionKind, AnonPointeeRegionKind,
|
AnonPointeeRegionKind,
|
||||||
END_TYPED_REGIONS };
|
END_TYPED_REGIONS };
|
||||||
private:
|
private:
|
||||||
const Kind kind;
|
const Kind kind;
|
||||||
|
@ -199,51 +199,33 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// AnonTypedRegion - An "anonymous" region that simply types a chunk
|
/// AnonPointeeRegion - anonymous regions pointed-to by pointer function
|
||||||
/// of memory.
|
|
||||||
class AnonTypedRegion : public TypedRegion {
|
|
||||||
protected:
|
|
||||||
QualType T;
|
|
||||||
|
|
||||||
friend class MemRegionManager;
|
|
||||||
|
|
||||||
AnonTypedRegion(QualType t, MemRegion* sreg)
|
|
||||||
: TypedRegion(sreg, AnonTypedRegionKind), T(t) {}
|
|
||||||
|
|
||||||
static void ProfileRegion(llvm::FoldingSetNodeID& ID, QualType T,
|
|
||||||
const MemRegion* superRegion);
|
|
||||||
|
|
||||||
public:
|
|
||||||
QualType getType(ASTContext& C) const { return C.getCanonicalType(T); }
|
|
||||||
|
|
||||||
|
|
||||||
void Profile(llvm::FoldingSetNodeID& ID) const;
|
|
||||||
|
|
||||||
static bool classof(const MemRegion* R) {
|
|
||||||
return R->getKind() == AnonTypedRegionKind;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// AnonPointeeRegion - anonymous regions pointed-at by pointer function
|
|
||||||
/// parameters or pointer globals. In RegionStoreManager, we assume pointer
|
/// parameters or pointer globals. In RegionStoreManager, we assume pointer
|
||||||
/// parameters or globals point at some anonymous region initially. Such
|
/// parameters or globals point at some anonymous region. Such regions are not
|
||||||
/// regions are not the regions associated with the pointers themselves, but
|
/// the regions associated with the pointer variables themselves. They are
|
||||||
/// are identified with the VarDecl of the parameters or globals.
|
/// identified with the VarDecl of the pointer variable. We create them lazily.
|
||||||
class AnonPointeeRegion : public AnonTypedRegion {
|
|
||||||
|
class AnonPointeeRegion : public TypedRegion {
|
||||||
friend class MemRegionManager;
|
friend class MemRegionManager;
|
||||||
// VD - the pointer variable that points at this region.
|
// VD - the pointer variable that points at this region.
|
||||||
const VarDecl* VD;
|
const VarDecl* Pointer;
|
||||||
|
|
||||||
AnonPointeeRegion(const VarDecl* d, QualType t, MemRegion* sreg)
|
AnonPointeeRegion(const VarDecl* d, MemRegion* sreg)
|
||||||
: AnonTypedRegion(t, sreg), VD(d) {}
|
: TypedRegion(sreg, AnonPointeeRegionKind), Pointer(d) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static void ProfileRegion(llvm::FoldingSetNodeID& ID, const VarDecl* PVD,
|
QualType getType(ASTContext& C) const;
|
||||||
QualType T, const MemRegion* superRegion);
|
|
||||||
};
|
|
||||||
|
|
||||||
/// AnonHeapRegion - anonymous region created by malloc().
|
static void ProfileRegion(llvm::FoldingSetNodeID& ID, const VarDecl* PVD,
|
||||||
class AnonHeapRegion : public AnonTypedRegion {
|
const MemRegion* superRegion);
|
||||||
|
|
||||||
|
void Profile(llvm::FoldingSetNodeID& ID) const {
|
||||||
|
ProfileRegion(ID, Pointer, superRegion);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool classof(const MemRegion* R) {
|
||||||
|
return R->getKind() == AnonPointeeRegionKind;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// CompoundLiteralRegion - A memory region representing a compound literal.
|
/// CompoundLiteralRegion - A memory region representing a compound literal.
|
||||||
|
|
|
@ -44,26 +44,22 @@ void AllocaRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
||||||
ProfileRegion(ID, Ex, Cnt);
|
ProfileRegion(ID, Ex, Cnt);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnonTypedRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, QualType T,
|
QualType AnonPointeeRegion::getType(ASTContext& C) const {
|
||||||
const MemRegion* superRegion) {
|
QualType T = C.getCanonicalType(Pointer->getType());
|
||||||
ID.AddInteger((unsigned) AnonTypedRegionKind);
|
PointerType* PTy = cast<PointerType>(T.getTypePtr());
|
||||||
ID.Add(T);
|
|
||||||
ID.AddPointer(superRegion);
|
QualType PointeeTy = C.getCanonicalType(PTy->getPointeeType());
|
||||||
|
return PointeeTy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnonPointeeRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
|
void AnonPointeeRegion::ProfileRegion(llvm::FoldingSetNodeID& ID,
|
||||||
const VarDecl* VD, QualType T,
|
const VarDecl* VD,
|
||||||
const MemRegion* superRegion) {
|
const MemRegion* superRegion) {
|
||||||
ID.AddInteger((unsigned) AnonPointeeRegionKind);
|
ID.AddInteger((unsigned) AnonPointeeRegionKind);
|
||||||
ID.Add(T);
|
|
||||||
ID.AddPointer(VD);
|
ID.AddPointer(VD);
|
||||||
ID.AddPointer(superRegion);
|
ID.AddPointer(superRegion);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AnonTypedRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
|
||||||
AnonTypedRegion::ProfileRegion(ID, T, superRegion);
|
|
||||||
}
|
|
||||||
|
|
||||||
void CompoundLiteralRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
void CompoundLiteralRegion::Profile(llvm::FoldingSetNodeID& ID) const {
|
||||||
CompoundLiteralRegion::ProfileRegion(ID, CL, superRegion);
|
CompoundLiteralRegion::ProfileRegion(ID, CL, superRegion);
|
||||||
}
|
}
|
||||||
|
@ -346,11 +342,9 @@ MemRegionManager::getObjCObjectRegion(const ObjCInterfaceDecl* d,
|
||||||
|
|
||||||
AnonPointeeRegion* MemRegionManager::getAnonPointeeRegion(const VarDecl* d) {
|
AnonPointeeRegion* MemRegionManager::getAnonPointeeRegion(const VarDecl* d) {
|
||||||
llvm::FoldingSetNodeID ID;
|
llvm::FoldingSetNodeID ID;
|
||||||
QualType T = d->getType();
|
|
||||||
QualType PointeeType = cast<PointerType>(T.getTypePtr())->getPointeeType();
|
|
||||||
MemRegion* superRegion = getUnknownRegion();
|
MemRegion* superRegion = getUnknownRegion();
|
||||||
|
|
||||||
AnonPointeeRegion::ProfileRegion(ID, d, PointeeType, superRegion);
|
AnonPointeeRegion::ProfileRegion(ID, d, superRegion);
|
||||||
|
|
||||||
void* InsertPos;
|
void* InsertPos;
|
||||||
MemRegion* data = Regions.FindNodeOrInsertPos(ID, InsertPos);
|
MemRegion* data = Regions.FindNodeOrInsertPos(ID, InsertPos);
|
||||||
|
@ -358,7 +352,7 @@ AnonPointeeRegion* MemRegionManager::getAnonPointeeRegion(const VarDecl* d) {
|
||||||
|
|
||||||
if (!R) {
|
if (!R) {
|
||||||
R = (AnonPointeeRegion*) A.Allocate<AnonPointeeRegion>();
|
R = (AnonPointeeRegion*) A.Allocate<AnonPointeeRegion>();
|
||||||
new (R) AnonPointeeRegion(d, PointeeType, superRegion);
|
new (R) AnonPointeeRegion(d, superRegion);
|
||||||
Regions.InsertNode(R, InsertPos);
|
Regions.InsertNode(R, InsertPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue