MemRegionManager: Migrate logic for getCodeTextRegion() over to using

trait-based MemRegion creation.

llvm-svn: 73941
This commit is contained in:
Zhongxing Xu 2009-06-23 03:50:30 +00:00
parent 1a195b264f
commit cbfc7d6c2e
2 changed files with 17 additions and 30 deletions

View File

@ -249,7 +249,7 @@ public:
void Profile(llvm::FoldingSetNodeID& ID) const;
static void ProfileRegion(llvm::FoldingSetNodeID& ID,
const void* data, QualType t);
const void* data, QualType t, const MemRegion*);
static bool classof(const MemRegion* R) {
return R->getKind() == CodeTextRegionKind;
@ -793,7 +793,18 @@ template <> struct MemRegionManagerTrait<SymbolicRegion> {
return MRMgr.getUnknownRegion();
}
};
template<> struct MemRegionManagerTrait<CodeTextRegion> {
typedef MemSpaceRegion SuperRegionTy;
static const SuperRegionTy* getSuperRegion(MemRegionManager& MRMgr,
const FunctionDecl*, QualType) {
return MRMgr.getCodeRegion();
}
static const SuperRegionTy* getSuperRegion(MemRegionManager& MRMgr,
SymbolRef, QualType) {
return MRMgr.getCodeRegion();
}
};
} // end clang namespace

View File

@ -129,14 +129,14 @@ void ElementRegion::Profile(llvm::FoldingSetNodeID& ID) const {
}
void CodeTextRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, const void* data,
QualType t) {
QualType t, const MemRegion*) {
ID.AddInteger(MemRegion::CodeTextRegionKind);
ID.AddPointer(data);
ID.Add(t);
}
void CodeTextRegion::Profile(llvm::FoldingSetNodeID& ID) const {
CodeTextRegion::ProfileRegion(ID, Data, LocationType);
CodeTextRegion::ProfileRegion(ID, Data, LocationType, superRegion);
}
//===----------------------------------------------------------------------===//
@ -275,35 +275,11 @@ MemRegionManager::getElementRegion(QualType elementType, SVal Idx,
CodeTextRegion* MemRegionManager::getCodeTextRegion(const FunctionDecl* fd,
QualType t) {
llvm::FoldingSetNodeID ID;
CodeTextRegion::ProfileRegion(ID, fd, t);
void* InsertPos;
MemRegion* data = Regions.FindNodeOrInsertPos(ID, InsertPos);
CodeTextRegion* R = cast_or_null<CodeTextRegion>(data);
if (!R) {
R = (CodeTextRegion*) A.Allocate<CodeTextRegion>();
new (R) CodeTextRegion(fd, t, getCodeRegion());
Regions.InsertNode(R, InsertPos);
}
return R;
return getRegion<CodeTextRegion>(fd, t);
}
CodeTextRegion* MemRegionManager::getCodeTextRegion(SymbolRef sym, QualType t) {
llvm::FoldingSetNodeID ID;
CodeTextRegion::ProfileRegion(ID, sym, t);
void* InsertPos;
MemRegion* data = Regions.FindNodeOrInsertPos(ID, InsertPos);
CodeTextRegion* R = cast_or_null<CodeTextRegion>(data);
if (!R) {
R = (CodeTextRegion*) A.Allocate<CodeTextRegion>();
new (R) CodeTextRegion(sym, t, getCodeRegion());
Regions.InsertNode(R, InsertPos);
}
return R;
return getRegion<CodeTextRegion>(sym, t);
}
/// getSymbolicRegion - Retrieve or create a "symbolic" memory region.