diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-07-29 18:14:27 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-07-29 18:14:27 +0000 |
commit | 0e3ec3ff2477e60f0ceda922cc2e3a25a59d81f2 (patch) | |
tree | 192fdbada0d27ec818dafaf7f32bb1d634d5e2f5 /lib/Analysis/MemRegion.cpp | |
parent | 4e6e0d70e759bad13a36809b23fd7205c9cc1f91 (diff) |
Add 'MemRegion::getBaseRegion()', a utility method to strip ElementRegions with
index 0. This will be used for refinements to InvalidateRegion and CastRegion.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77481 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/MemRegion.cpp')
-rw-r--r-- | lib/Analysis/MemRegion.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/Analysis/MemRegion.cpp b/lib/Analysis/MemRegion.cpp index 9b8f7c81e1..a708bd3068 100644 --- a/lib/Analysis/MemRegion.cpp +++ b/lib/Analysis/MemRegion.cpp @@ -398,3 +398,23 @@ const MemRegion *TypedViewRegion::removeViews() const { } return R; } + +const MemRegion *MemRegion::getBaseRegion() const { + const MemRegion *R = this; + while (true) { + if (const ElementRegion *ER = dyn_cast<ElementRegion>(R)) { + // FIXME: generalize. Essentially we want to strip away ElementRegions + // that were layered on a symbolic region because of casts. We only + // want to strip away ElementRegions, however, where the index is 0. + SVal index = ER->getIndex(); + if (nonloc::ConcreteInt *CI = dyn_cast<nonloc::ConcreteInt>(&index)) { + if (CI->getValue().getZExtValue() == 0) { + R = ER->getSuperRegion(); + continue; + } + } + } + break; + } + return R; +} |