From beac9e3772e255f89dad0abe34811953121912b2 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Wed, 9 Jan 2013 18:46:17 +0000 Subject: [PATCH] Do not model loads from complex types, since we don't accurately model the imaginary and real parts yet. Fixes false positive reported in . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171987 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/StaticAnalyzer/Core/RegionStore.cpp | 5 +++++ test/Analysis/misc-ps-region-store.cpp | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lib/StaticAnalyzer/Core/RegionStore.cpp b/lib/StaticAnalyzer/Core/RegionStore.cpp index 9d66c16e73..ffdb97197f 100644 --- a/lib/StaticAnalyzer/Core/RegionStore.cpp +++ b/lib/StaticAnalyzer/Core/RegionStore.cpp @@ -1133,6 +1133,11 @@ SVal RegionStoreManager::getBinding(RegionBindingsConstRef B, Loc L, QualType T) const TypedValueRegion *R = cast(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 = ...; diff --git a/test/Analysis/misc-ps-region-store.cpp b/test/Analysis/misc-ps-region-store.cpp index 7b7b8bd300..de70d3b754 100644 --- a/test/Analysis/misc-ps-region-store.cpp +++ b/test/Analysis/misc-ps-region-store.cpp @@ -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 +} + -- 2.40.0