[cfe-commits] r171987 - in /cfe/trunk: lib/StaticAnalyzer/Core/RegionStore.cpp test/Analysis/misc-ps-region-store.cpp
Ted Kremenek
kremenek at apple.com
Wed Jan 9 10:46:18 PST 2013
Author: kremenek
Date: Wed Jan 9 12:46:17 2013
New Revision: 171987
URL: http://llvm.org/viewvc/llvm-project?rev=171987&view=rev
Log:
Do not model loads from complex types, since we don't accurately model the imaginary and real parts yet.
Fixes false positive reported in <rdar://problem/12964481>.
Modified:
cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
cfe/trunk/test/Analysis/misc-ps-region-store.cpp
Modified: cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp?rev=171987&r1=171986&r2=171987&view=diff
==============================================================================
--- cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/RegionStore.cpp Wed Jan 9 12:46:17 2013
@@ -1133,6 +1133,11 @@
const TypedValueRegion *R = cast<TypedValueRegion>(MR);
QualType RTy = R->getValueType();
+ // FIXME: we do not yet model the parts of a complex type, so treat the
+ // whole thing as "unknown".
+ if (RTy->isAnyComplexType())
+ return UnknownVal();
+
// FIXME: We should eventually handle funny addressing. e.g.:
//
// int x = ...;
Modified: cfe/trunk/test/Analysis/misc-ps-region-store.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps-region-store.cpp?rev=171987&r1=171986&r2=171987&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps-region-store.cpp (original)
+++ cfe/trunk/test/Analysis/misc-ps-region-store.cpp Wed Jan 9 12:46:17 2013
@@ -705,3 +705,19 @@
*p = 0xDEADBEEF; // no-warning
}
}
+
+// The analyzer currently does not model complex types. Test that the load
+// from 'x' is not flagged as being uninitialized.
+typedef __complex__ float _ComplexT;
+void rdar12964481(_ComplexT *y) {
+ _ComplexT x;
+ __real__ x = 1.0;
+ __imag__ x = 1.0;
+ *y *= x; // no-warning
+}
+void rdar12964481_b(_ComplexT *y) {
+ _ComplexT x;
+ // Eventually this should be a warning.
+ *y *= x; // no-warning
+}
+
More information about the cfe-commits
mailing list