From: Ted Kremenek Date: Fri, 11 Jan 2013 23:36:25 +0000 (+0000) Subject: Refine analyzer's handling of unary '!' and floating types to not assert. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9195caf28f2a5dcef1e299bf3e5232a018ca1c68;p=clang Refine analyzer's handling of unary '!' and floating types to not assert. Fixes PR 14634 and . git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172274 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/StaticAnalyzer/Core/ExprEngineC.cpp b/lib/StaticAnalyzer/Core/ExprEngineC.cpp index 1253f8888c..f1ef0f6601 100644 --- a/lib/StaticAnalyzer/Core/ExprEngineC.cpp +++ b/lib/StaticAnalyzer/Core/ExprEngineC.cpp @@ -809,7 +809,10 @@ void ExprEngine::VisitUnaryOperator(const UnaryOperator* U, Result = evalBinOp(state, BO_EQ, cast(V), X, U->getType()); } - else { + else if (Ex->getType()->isFloatingType()) { + // FIXME: handle floating point types. + Result = UnknownVal(); + } else { nonloc::ConcreteInt X(getBasicVals().getValue(0, Ex->getType())); Result = evalBinOp(state, BO_EQ, cast(V), X, U->getType()); diff --git a/test/Analysis/misc-ps.c b/test/Analysis/misc-ps.c index ef65e0d731..5369ab1061 100644 --- a/test/Analysis/misc-ps.c +++ b/test/Analysis/misc-ps.c @@ -157,3 +157,9 @@ void PR14635(int *p) { *p = a || b; // expected-warning {{Assigned value is garbage or undefined}} } +// Test handling floating point values with unary '!'. +int PR14634(int x) { + double y = (double)x; + return !y; +} +