[cfe-commits] r133937 - in /cfe/trunk: lib/StaticAnalyzer/Core/RegionStore.cpp test/Analysis/uninit-vals-ps-region.m test/Analysis/uninit-vals.m
Jordy Rose
jediknil at belkadan.com
Mon Jun 27 13:36:38 PDT 2011
Author: jrose
Date: Mon Jun 27 15:36:38 2011
New Revision: 133937
URL: http://llvm.org/viewvc/llvm-project?rev=133937&view=rev
Log:
[analyzer] Use UnknownVal when default-initializing arrays whose element types we don't model, to distinguish them from uninitialized arrays (PR10163).
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
cfe/trunk/test/Analysis/uninit-vals-ps-region.m
cfe/trunk/test/Analysis/uninit-vals.m
Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=133937&r1=133936&r2=133937&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Mon Jun 27 15:36:38 2011
@@ -1377,7 +1377,12 @@
V = svalBuilder.makeZeroVal(Ctx.IntTy);
}
else {
- return StoreRef(store, *this);
+ // We can't represent values of this type, but we still need to set a value
+ // to record that the region has been initialized.
+ // If this assertion ever fires, a new case should be added above -- we
+ // should know how to default-initialize any value we can symbolicate.
+ assert(!SymbolManager::canSymbolicate(T) && "This type is representable");
+ V = UnknownVal();
}
return StoreRef(addBinding(B, R, BindingKey::Default,
Modified: cfe/trunk/test/Analysis/uninit-vals-ps-region.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/uninit-vals-ps-region.m?rev=133937&r1=133936&r2=133937&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/uninit-vals-ps-region.m (original)
+++ cfe/trunk/test/Analysis/uninit-vals-ps-region.m Mon Jun 27 15:36:38 2011
@@ -67,3 +67,12 @@
b.x |= 1; // expected-warning{{The left expression of the compound assignment is an uninitialized value. The computed value will also be garbage}}
}
+
+// The flip side of PR10163 -- float arrays that are actually uninitialized
+// (The main test is in uninit-vals.m)
+void test_PR10163(float);
+void PR10163 (void) {
+ float x[2];
+ test_PR10163(x[1]); // expected-warning{{uninitialized value}}
+}
+
Modified: cfe/trunk/test/Analysis/uninit-vals.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/uninit-vals.m?rev=133937&r1=133936&r2=133937&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/uninit-vals.m (original)
+++ cfe/trunk/test/Analysis/uninit-vals.m Mon Jun 27 15:36:38 2011
@@ -23,3 +23,12 @@
return n;
}
+
+
+// PR10163 -- don't warn for default-initialized float arrays.
+// (An additional test is in uninit-vals-ps-region.m)
+void test_PR10163(float);
+void PR10163 (void) {
+ float x[2] = {0};
+ test_PR10163(x[1]); // no-warning
+}
More information about the cfe-commits
mailing list