aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis/BasicStore.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-01-27 18:29:03 +0000
committerTed Kremenek <kremenek@apple.com>2009-01-27 18:29:03 +0000
commitd76d47eb5f5afffcf25fe8c42521867ccad4073b (patch)
treef31ddf18ad78e05942af7d57ff747d8706443671 /lib/Analysis/BasicStore.cpp
parent34ebde404dc17d89487b07e6daaf1b47d5dfee39 (diff)
Fix bug in BasicStore::getLValueElement where if the base of an array subscript expression was an ElementRegion we stacked another ElementRegion on top of that.
This fixes PR 3422. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63110 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BasicStore.cpp')
-rw-r--r--lib/Analysis/BasicStore.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp
index a36a239e0d..2feea594b8 100644
--- a/lib/Analysis/BasicStore.cpp
+++ b/lib/Analysis/BasicStore.cpp
@@ -203,7 +203,6 @@ SVal BasicStoreManager::getLValueField(const GRState* St, SVal Base,
SVal BasicStoreManager::getLValueElement(const GRState* St, SVal Base,
SVal Offset) {
-
if (Base.isUnknownOrUndef())
return Base;
@@ -233,6 +232,17 @@ SVal BasicStoreManager::getLValueElement(const GRState* St, SVal Base,
case loc::MemRegionKind: {
const MemRegion *R = cast<loc::MemRegionVal>(BaseL).getRegion();
+
+ if (isa<ElementRegion>(R)) {
+ // Basic example:
+ // char buf[100];
+ // char *q = &buf[1]; // p points to ElementRegion(buf,Unknown)
+ // &q[10]
+ assert(cast<ElementRegion>(R)->getIndex().isUnknown());
+ return Base;
+ }
+
+
if (const TypedRegion *TR = dyn_cast<TypedRegion>(R)) {
BaseR = TR;
break;
@@ -244,7 +254,7 @@ SVal BasicStoreManager::getLValueElement(const GRState* St, SVal Base,
break;
}
-
+
case loc::ConcreteIntKind:
// While these seem funny, this can happen through casts.
// FIXME: What we should return is the field offset. For example,