Fix pr6035.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93422 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/SValuator.cpp b/lib/Analysis/SValuator.cpp
index 0e56026..8392fcf 100644
--- a/lib/Analysis/SValuator.cpp
+++ b/lib/Analysis/SValuator.cpp
@@ -66,6 +66,9 @@
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 4b72916..e106f34 100644
--- a/test/Analysis/casts.c
+++ b/test/Analysis/casts.c
@@ -57,3 +57,14 @@
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;
+}