[cfe-commits] r73941 - in /cfe/trunk: include/clang/Analysis/PathSensitive/MemRegion.h lib/Analysis/MemRegion.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Mon Jun 22 20:50:37 PDT 2009
Author: zhongxingxu
Date: Mon Jun 22 22:50:30 2009
New Revision: 73941
URL: http://llvm.org/viewvc/llvm-project?rev=73941&view=rev
Log:
MemRegionManager: Migrate logic for getCodeTextRegion() over to using
trait-based MemRegion creation.
Modified:
cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
cfe/trunk/lib/Analysis/MemRegion.cpp
Modified: cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h?rev=73941&r1=73940&r2=73941&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/Analysis/PathSensitive/MemRegion.h Mon Jun 22 22:50:30 2009
@@ -249,7 +249,7 @@
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 @@
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
Modified: cfe/trunk/lib/Analysis/MemRegion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/MemRegion.cpp?rev=73941&r1=73940&r2=73941&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/MemRegion.cpp (original)
+++ cfe/trunk/lib/Analysis/MemRegion.cpp Mon Jun 22 22:50:30 2009
@@ -129,14 +129,14 @@
}
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 @@
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.
More information about the cfe-commits
mailing list