diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-02-09 19:11:53 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-02-09 19:11:53 +0000 |
commit | 8ec4aac6d3dee698e4cb7b9f540d962e4ccab468 (patch) | |
tree | 8e0545ac4016b989f20d5df8a37f38b9b782e18c /lib/Checker/RegionStore.cpp | |
parent | d5322da6ba08728fe4ee9b14f468961eddc915dc (diff) |
Fix lookup of fields from lazy bindings to check if the region is
NULL, not the store, to determine if a lookup succeeded. The store
can be null if it contained no bindings. This fixes a false positive
reported to me by a user of the analyzer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95679 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Checker/RegionStore.cpp')
-rw-r--r-- | lib/Checker/RegionStore.cpp | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/lib/Checker/RegionStore.cpp b/lib/Checker/RegionStore.cpp index c08be0cff6..a6646436d5 100644 --- a/lib/Checker/RegionStore.cpp +++ b/lib/Checker/RegionStore.cpp @@ -1054,7 +1054,7 @@ RegionStoreManager::GetLazyBinding(RegionBindings B, const MemRegion *R) { const std::pair<Store, const MemRegion *> &X = GetLazyBinding(B, ER->getSuperRegion()); - if (X.first) + if (X.second) return std::make_pair(X.first, MRMgr.getElementRegionWithSuper(ER, X.second)); } @@ -1062,7 +1062,7 @@ RegionStoreManager::GetLazyBinding(RegionBindings B, const MemRegion *R) { const std::pair<Store, const MemRegion *> &X = GetLazyBinding(B, FR->getSuperRegion()); - if (X.first) + if (X.second) return std::make_pair(X.first, MRMgr.getFieldRegionWithSuper(FR, X.second)); } @@ -1179,13 +1179,9 @@ SVal RegionStoreManager::RetrieveFieldOrElementCommon(Store store, const MemRegion *lazyBindingRegion = NULL; llvm::tie(lazyBindingStore, lazyBindingRegion) = GetLazyBinding(B, R); - if (lazyBindingStore) { - assert(lazyBindingRegion && "Lazy-binding region not set"); - - if (isa<ElementRegion>(R)) - return RetrieveElement(lazyBindingStore, - cast<ElementRegion>(lazyBindingRegion)); - + if (lazyBindingRegion) { + if (const ElementRegion *ER = dyn_cast<ElementRegion>(lazyBindingRegion)) + return RetrieveElement(lazyBindingStore, ER); return RetrieveField(lazyBindingStore, cast<FieldRegion>(lazyBindingRegion)); } |