diff options
author | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-11-10 02:37:53 +0000 |
---|---|---|
committer | Zhongxing Xu <xuzhongxing@gmail.com> | 2009-11-10 02:37:53 +0000 |
commit | adca27102ff733c7d42fcbbc2c7e134a7fc026f9 (patch) | |
tree | 78a3b7bea08e6d6b7ae3d735699ef157381b7094 /lib/Analysis/MemRegion.cpp | |
parent | fbfb52d4cf10b4fd1ac19d1445fe2ffcb9c2bbf1 (diff) |
Refine PointerSubChecker: compare the base region instead of the original
region, so that arithmetic within a memory chunk is allowed.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@86652 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MemRegion.cpp')
-rw-r--r-- | lib/Analysis/MemRegion.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Analysis/MemRegion.cpp b/lib/Analysis/MemRegion.cpp index ad3d36e79d..8c0b85c0c7 100644 --- a/lib/Analysis/MemRegion.cpp +++ b/lib/Analysis/MemRegion.cpp @@ -378,6 +378,24 @@ bool MemRegion::hasGlobalsOrParametersStorage() const { return false; } +// getBaseRegion strips away all elements and fields, and get the base region +// of them. +const MemRegion *MemRegion::getBaseRegion() const { + const MemRegion *R = this; + while (true) { + if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) { + R = ER->getSuperRegion(); + continue; + } + if (const FieldRegion *FR = dyn_cast<FieldRegion>(R)) { + R = FR->getSuperRegion(); + continue; + } + break; + } + return R; +} + //===----------------------------------------------------------------------===// // View handling. //===----------------------------------------------------------------------===// |