diff options
-rw-r--r-- | lib/Analysis/RegionStore.cpp | 6 | ||||
-rw-r--r-- | test/Analysis/misc-ps.m | 11 |
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp index c47aaa20e0..70201759e1 100644 --- a/lib/Analysis/RegionStore.cpp +++ b/lib/Analysis/RegionStore.cpp @@ -121,8 +121,10 @@ class VISIBILITY_HIDDEN RegionStoreSubRegionMap : public SubRegionMap { public: void add(const MemRegion* Parent, const MemRegion* SubRegion) { Map::iterator I = M.find(Parent); - M.insert(std::make_pair(Parent, - F.Add(I == M.end() ? F.GetEmptySet() : I->second, SubRegion))); + if (I == M.end()) + M.insert(std::make_pair(Parent, F.Add(F.GetEmptySet(), SubRegion))); + else + I->second = F.Add(I->second, SubRegion); } ~RegionStoreSubRegionMap() {} diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index 9f48db55d1..1ca209dbf8 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -522,3 +522,14 @@ void test_pass_val() { test_pass_val_aux(s); } +// This is a reduced test case of a false positive that previously appeared +// in RegionStoreManager. Previously the array access resulted in dereferencing +// an undefined value. +int test_array_compound(int *q, int *r, int *z) { + int *array[] = { q, r, z }; + int j = 0; + for (unsigned i = 0; i < 3 ; ++i) + if (*array[i]) ++j; // no-warning + return j; +} + |