]> granicus.if.org Git - clang/commitdiff
Do not model loads from complex types, since we don't accurately model the imaginary...
authorTed Kremenek <kremenek@apple.com>
Wed, 9 Jan 2013 18:46:17 +0000 (18:46 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 9 Jan 2013 18:46:17 +0000 (18:46 +0000)
Fixes false positive reported in <rdar://problem/12964481>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171987 91177308-0d34-0410-b5e6-96231b3b80d8

lib/StaticAnalyzer/Core/RegionStore.cpp
test/Analysis/misc-ps-region-store.cpp

index 9d66c16e73e6b72a97cb57c2830170de6629b553..ffdb97197f1d6a212474b62056d054670a9474c2 100644 (file)
@@ -1133,6 +1133,11 @@ SVal RegionStoreManager::getBinding(RegionBindingsConstRef B, Loc L, QualType T)
   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 = ...;
index 7b7b8bd300912e5687e4d62b8924552b1407559a..de70d3b754dff80db304c304f8f1480697a224b2 100644 (file)
@@ -705,3 +705,19 @@ void rdar12759044() {
    *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
+}
+