diff options
| author | Ted Kremenek <kremenek@apple.com> | 2009-01-27 18:29:03 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2009-01-27 18:29:03 +0000 |
| commit | 422d81dcd4b0c5fd4538a2feaf0ec4df5f5bf7b1 (patch) | |
| tree | ae8e2ceec5558f7a4aa20a371da0ec43f85c437e /clang/lib/Analysis | |
| parent | a3402cd52403e07013edf952ce9e70685bcc4ead (diff) | |
| download | bcm5719-llvm-422d81dcd4b0c5fd4538a2feaf0ec4df5f5bf7b1.tar.gz bcm5719-llvm-422d81dcd4b0c5fd4538a2feaf0ec4df5f5bf7b1.zip | |
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.
llvm-svn: 63110
Diffstat (limited to 'clang/lib/Analysis')
| -rw-r--r-- | clang/lib/Analysis/BasicStore.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/clang/lib/Analysis/BasicStore.cpp b/clang/lib/Analysis/BasicStore.cpp index a36a239e0de..2feea594b8a 100644 --- a/clang/lib/Analysis/BasicStore.cpp +++ b/clang/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, |

