[cfe-commits] r95128 - in /cfe/trunk: lib/Checker/SValuator.cpp test/Analysis/misc-ps.m
Ted Kremenek
kremenek at apple.com
Tue Feb 2 13:11:41 PST 2010
Author: kremenek
Date: Tue Feb 2 15:11:40 2010
New Revision: 95128
URL: http://llvm.org/viewvc/llvm-project?rev=95128&view=rev
Log:
Explicitly check for casts to double or complex types instead of possibly asserting in SValuator.
Modified:
cfe/trunk/lib/Checker/SValuator.cpp
cfe/trunk/test/Analysis/misc-ps.m
Modified: cfe/trunk/lib/Checker/SValuator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Checker/SValuator.cpp?rev=95128&r1=95127&r2=95128&view=diff
==============================================================================
--- cfe/trunk/lib/Checker/SValuator.cpp (original)
+++ cfe/trunk/lib/Checker/SValuator.cpp Tue Feb 2 15:11:40 2010
@@ -66,6 +66,12 @@
if (C.hasSameUnqualifiedType(castTy, originalTy))
return CastResult(state, val);
+ // Check for casts to real or complex numbers. We don't handle these at all
+ // right now.
+ if (castTy->isFloatingType() || castTy->isAnyComplexType())
+ return CastResult(state, UnknownVal());
+
+ // Check for casts from integers to integers.
if (castTy->isIntegerType() && originalTy->isIntegerType())
return CastResult(state, EvalCastNL(cast<NonLoc>(val), castTy));
Modified: cfe/trunk/test/Analysis/misc-ps.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/misc-ps.m?rev=95128&r1=95127&r2=95128&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/misc-ps.m (original)
+++ cfe/trunk/test/Analysis/misc-ps.m Tue Feb 2 15:11:40 2010
@@ -851,3 +851,18 @@
// Previously we got a false positive about 'v' being uninitialized.
return v; // no-warning
}
+
+//===----------------------------------------------------------------------===//
+// Handle casts from symbolic regions (packaged as integers) to doubles.
+// Previously this caused an assertion failure.
+//===----------------------------------------------------------------------===//
+
+void *foo_rev95119();
+void baz_rev95119(double x);
+void bar_rev95119() {
+ // foo_rev95119() returns a symbolic pointer. It is then
+ // cast to an int which is then cast to a double.
+ int value = (int) foo_rev95119();
+ baz_rev95119((double)value);
+}
+
More information about the cfe-commits
mailing list