aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Analysis/SValuator.cpp3
-rw-r--r--test/Analysis/casts.c11
2 files changed, 14 insertions, 0 deletions
diff --git a/lib/Analysis/SValuator.cpp b/lib/Analysis/SValuator.cpp
index 0e56026bb4..8392fcf65a 100644
--- a/lib/Analysis/SValuator.cpp
+++ b/lib/Analysis/SValuator.cpp
@@ -66,6 +66,9 @@ SValuator::CastResult SValuator::EvalCast(SVal val, const GRState *state,
if (C.hasSameUnqualifiedType(castTy, originalTy))
return CastResult(state, val);
+ if (castTy->isIntegerType() && originalTy->isIntegerType())
+ return CastResult(state, EvalCastNL(cast<NonLoc>(val), castTy));
+
// Check for casts from pointers to integers.
if (castTy->isIntegerType() && Loc::IsLocType(originalTy))
return CastResult(state, EvalCastL(cast<Loc>(val), castTy));
diff --git a/test/Analysis/casts.c b/test/Analysis/casts.c
index 4b72916171..e106f34832 100644
--- a/test/Analysis/casts.c
+++ b/test/Analysis/casts.c
@@ -57,3 +57,14 @@ void doit(char *data, int len) {
memcpy(buf, data, len);
}
}
+
+struct pcm_feeder {
+ void *data;
+};
+// Test cast a pointer to long and then to int does not crash SValuator.
+void feed_swaplr (struct pcm_feeder *f)
+{
+ int bps;
+ bps = (long) f->data;
+ (void) bps;
+}