summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis/MemRegion.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-07-29 18:14:27 +0000
committerTed Kremenek <kremenek@apple.com>2009-07-29 18:14:27 +0000
commitccf3335939bfa68ac3e3af1b21f3a2895686d1f3 (patch)
treee7e836aa19d03a6c2793be61d38a432d8efb75e4 /clang/lib/Analysis/MemRegion.cpp
parent77268a56ffc396158460b3c9620dded03ed937cf (diff)
downloadbcm5719-llvm-ccf3335939bfa68ac3e3af1b21f3a2895686d1f3.tar.gz
bcm5719-llvm-ccf3335939bfa68ac3e3af1b21f3a2895686d1f3.zip
Add 'MemRegion::getBaseRegion()', a utility method to strip ElementRegions with
index 0. This will be used for refinements to InvalidateRegion and CastRegion. llvm-svn: 77481
Diffstat (limited to 'clang/lib/Analysis/MemRegion.cpp')
-rw-r--r--clang/lib/Analysis/MemRegion.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/Analysis/MemRegion.cpp b/clang/lib/Analysis/MemRegion.cpp
index 9b8f7c81e1c..a708bd3068f 100644
--- a/clang/lib/Analysis/MemRegion.cpp
+++ b/clang/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;
+}
OpenPOWER on IntegriCloud