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; void Profile(llvm::FoldingSetNodeID& ID) const;
static void ProfileRegion(llvm::FoldingSetNodeID& ID, static void ProfileRegion(llvm::FoldingSetNodeID& ID,
const void* data, QualType t); const void* data, QualType t, const MemRegion*);
static bool classof(const MemRegion* R) { static bool classof(const MemRegion* R) {
return R->getKind() == CodeTextRegionKind; return R->getKind() == CodeTextRegionKind;
@ -793,7 +793,18 @@ template <> struct MemRegionManagerTrait<SymbolicRegion> {
return MRMgr.getUnknownRegion(); 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 } // 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, void CodeTextRegion::ProfileRegion(llvm::FoldingSetNodeID& ID, const void* data,
QualType t) { QualType t, const MemRegion*) {
ID.AddInteger(MemRegion::CodeTextRegionKind); ID.AddInteger(MemRegion::CodeTextRegionKind);
ID.AddPointer(data); ID.AddPointer(data);
ID.Add(t); ID.Add(t);
} }
void CodeTextRegion::Profile(llvm::FoldingSetNodeID& ID) const { 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, CodeTextRegion* MemRegionManager::getCodeTextRegion(const FunctionDecl* fd,
QualType t) { QualType t) {
llvm::FoldingSetNodeID ID; return getRegion<CodeTextRegion>(fd, t);
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;
} }
CodeTextRegion* MemRegionManager::getCodeTextRegion(SymbolRef sym, QualType t) { CodeTextRegion* MemRegionManager::getCodeTextRegion(SymbolRef sym, QualType t) {
llvm::FoldingSetNodeID ID; return getRegion<CodeTextRegion>(sym, t);
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;
} }
/// getSymbolicRegion - Retrieve or create a "symbolic" memory region. /// getSymbolicRegion - Retrieve or create a "symbolic" memory region.