[cfe-commits] r96472 - in /cfe/trunk: include/clang/Checker/PathSensitive/MemRegion.h lib/Checker/MemRegion.cpp
Zhongxing Xu
xuzhongxing at gmail.com
Wed Feb 17 00:46:50 PST 2010
Author: zhongxingxu
Date: Wed Feb 17 02:46:50 2010
New Revision: 96472
URL: http://llvm.org/viewvc/llvm-project?rev=96472&view=rev
Log:
For inline-based inter-procedural analysis, we will have multiple stack space regions. Use a dense map to store them.
Modified:
cfe/trunk/include/clang/Checker/PathSensitive/MemRegion.h
cfe/trunk/lib/Checker/MemRegion.cpp
Modified: cfe/trunk/include/clang/Checker/PathSensitive/MemRegion.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Checker/PathSensitive/MemRegion.h?rev=96472&r1=96471&r2=96472&view=diff
==============================================================================
--- cfe/trunk/include/clang/Checker/PathSensitive/MemRegion.h (original)
+++ cfe/trunk/include/clang/Checker/PathSensitive/MemRegion.h Wed Feb 17 02:46:50 2010
@@ -798,11 +798,10 @@
GlobalsSpaceRegion *globals;
- const StackFrameContext *cachedStackLocalsFrame;
- StackLocalsSpaceRegion *cachedStackLocalsRegion;
-
- const StackFrameContext *cachedStackArgumentsFrame;
- StackArgumentsSpaceRegion *cachedStackArgumentsRegion;
+ llvm::DenseMap<const StackFrameContext *, StackLocalsSpaceRegion *>
+ StackLocalsSpaceRegions;
+ llvm::DenseMap<const StackFrameContext *, StackArgumentsSpaceRegion *>
+ StackArgumentsSpaceRegions;
HeapSpaceRegion *heap;
UnknownSpaceRegion *unknown;
@@ -810,10 +809,7 @@
public:
MemRegionManager(ASTContext &c, llvm::BumpPtrAllocator& a)
- : C(c), A(a), globals(0),
- cachedStackLocalsFrame(0), cachedStackLocalsRegion(0),
- cachedStackArgumentsFrame(0), cachedStackArgumentsRegion(0),
- heap(0), unknown(0), code(0) {}
+ : C(c), A(a), globals(0), heap(0), unknown(0), code(0) {}
~MemRegionManager();
Modified: cfe/trunk/lib/Checker/MemRegion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/MemRegion.cpp?rev=96472&r1=96471&r2=96472&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/MemRegion.cpp (original)
+++ cfe/trunk/lib/Checker/MemRegion.cpp Wed Feb 17 02:46:50 2010
@@ -419,20 +419,27 @@
const StackLocalsSpaceRegion*
MemRegionManager::getStackLocalsRegion(const StackFrameContext *STC) {
assert(STC);
- if (STC == cachedStackLocalsFrame)
- return cachedStackLocalsRegion;
- cachedStackLocalsFrame = STC;
- return LazyAllocate(cachedStackLocalsRegion, STC);
+ StackLocalsSpaceRegion *&R = StackLocalsSpaceRegions[STC];
+
+ if (R)
+ return R;
+
+ R = A.Allocate<StackLocalsSpaceRegion>();
+ new (R) StackLocalsSpaceRegion(this, STC);
+ return R;
}
const StackArgumentsSpaceRegion *
MemRegionManager::getStackArgumentsRegion(const StackFrameContext *STC) {
assert(STC);
- if (STC == cachedStackArgumentsFrame)
- return cachedStackArgumentsRegion;
-
- cachedStackArgumentsFrame = STC;
- return LazyAllocate(cachedStackArgumentsRegion, STC);
+ StackArgumentsSpaceRegion *&R = StackArgumentsSpaceRegions[STC];
+
+ if (R)
+ return R;
+
+ R = A.Allocate<StackArgumentsSpaceRegion>();
+ new (R) StackArgumentsSpaceRegion(this, STC);
+ return R;
}
const GlobalsSpaceRegion *MemRegionManager::getGlobalsRegion() {
More information about the cfe-commits
mailing list