aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2013-01-11 23:36:25 +0000
committerTed Kremenek <kremenek@apple.com>2013-01-11 23:36:25 +0000
commit9195caf28f2a5dcef1e299bf3e5232a018ca1c68 (patch)
treec36c713b7891612c464849fa3afa258ae14bf431
parent2246823e207a4846c842a27cf99d99920cd2b178 (diff)
Refine analyzer's handling of unary '!' and floating types to not assert.
Fixes PR 14634 and <rdar://problem/12903080>. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172274 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/StaticAnalyzer/Core/ExprEngineC.cpp5
-rw-r--r--test/Analysis/misc-ps.c6
2 files changed, 10 insertions, 1 deletions
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<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());
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;
+}
+