diff options
author | Ted Kremenek <kremenek@apple.com> | 2010-02-02 21:11:40 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2010-02-02 21:11:40 +0000 |
commit | f68170481d4c36e1e930ee9a3bce58e2ae5a95cb (patch) | |
tree | 6dd1f966f9db86d23da5775f77a9a63830269256 | |
parent | 13c5c23d3e84ecfd37944a2773f72e4840225f90 (diff) |
Explicitly check for casts to double or complex types instead of possibly asserting in SValuator.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95128 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Checker/SValuator.cpp | 6 | ||||
-rw-r--r-- | test/Analysis/misc-ps.m | 15 |
2 files changed, 21 insertions, 0 deletions
diff --git a/lib/Checker/SValuator.cpp b/lib/Checker/SValuator.cpp index 66cd3193b1..fd2bbd06fb 100644 --- a/lib/Checker/SValuator.cpp +++ b/lib/Checker/SValuator.cpp @@ -66,6 +66,12 @@ SValuator::CastResult SValuator::EvalCast(SVal val, const GRState *state, 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)); diff --git a/test/Analysis/misc-ps.m b/test/Analysis/misc-ps.m index acf49f8e67..b31cd4cdd1 100644 --- a/test/Analysis/misc-ps.m +++ b/test/Analysis/misc-ps.m @@ -851,3 +851,18 @@ int rdar_7593875(int n) { // 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); +} + |