Refine analyzer's handling of unary '!' and floating types to not assert.
authorTed Kremenek <kremenek@apple.com>
Fri, 11 Jan 2013 23:36:25 +0000 (23:36 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 11 Jan 2013 23:36:25 +0000 (23:36 +0000)
Fixes PR 14634 and <rdar://problem/12903080>.

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

lib/StaticAnalyzer/Core/ExprEngineC.cpp
test/Analysis/misc-ps.c

index 1253f8888c76345cd922b6a710dce8416c3c08a6..f1ef0f6601189913dac71bf6a56692877fa15cd5 100644 (file)
@@ -809,7 +809,10 @@ void ExprEngine::VisitUnaryOperator(const UnaryOperator* U,
             Result = evalBinOp(state, BO_EQ, cast<Loc>(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<NonLoc>(V), X,
                                U->getType());
index ef65e0d731c431403375802ed0ab70691e7e3352..5369ab10615938f5917762856757dd995e053a61 100644 (file)
@@ -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;
+}
+