[cfe-commits] r78162 - in /cfe/trunk: lib/Analysis/RegionStore.cpp test/Analysis/misc-ps.m
Ted Kremenek
kremenek at apple.com
Tue Aug 4 22:31:05 PDT 2009
Author: kremenek
Date: Wed Aug 5 00:31:02 2009
New Revision: 78162
URL: http://llvm.org/viewvc/llvm-project?rev=78162&view=rev
Log:
Fix a bug in RegionStoreSubRegionManager::add() where multiple subregions wouldn't correctly get registered in the SubRegion map.
Modified:
cfe/trunk/lib/Analysis/RegionStore.cpp
cfe/trunk/test/Analysis/misc-ps.m
Modified: cfe/trunk/lib/Analysis/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/RegionStore.cpp?rev=78162&r1=78161&r2=78162&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/RegionStore.cpp (original)
+++ cfe/trunk/lib/Analysis/RegionStore.cpp Wed Aug 5 00:31:02 2009
@@ -121,8 +121,10 @@
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() {}
Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=78162&r1=78161&r2=78162&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Wed Aug 5 00:31:02 2009
@@ -522,3 +522,14 @@
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;
+}
+
More information about the cfe-commits
mailing list