Use new cast methods
This commit is contained in:
parent
630e17d3e4
commit
b478fcf270
1 changed files with 15 additions and 12 deletions
|
@ -128,23 +128,26 @@ impl<'tcx> ValueAnalysis<'tcx> for ConstAnalysis<'tcx> {
|
||||||
) -> ValueOrPlaceOrRef<Self::Value> {
|
) -> ValueOrPlaceOrRef<Self::Value> {
|
||||||
match rvalue {
|
match rvalue {
|
||||||
Rvalue::Cast(
|
Rvalue::Cast(
|
||||||
CastKind::IntToInt
|
kind @ (CastKind::IntToInt
|
||||||
| CastKind::FloatToInt
|
| CastKind::FloatToInt
|
||||||
| CastKind::FloatToFloat
|
| CastKind::FloatToFloat
|
||||||
| CastKind::IntToFloat,
|
| CastKind::IntToFloat),
|
||||||
operand,
|
operand,
|
||||||
ty,
|
ty,
|
||||||
) => {
|
) => match self.eval_operand(operand, state) {
|
||||||
let operand = self.eval_operand(operand, state);
|
FlatSet::Elem(op) => match kind {
|
||||||
match operand {
|
CastKind::IntToInt | CastKind::IntToFloat => {
|
||||||
FlatSet::Elem(operand) => self
|
self.ecx.int_to_int_or_float(&op, *ty)
|
||||||
.ecx
|
}
|
||||||
.misc_cast(&operand, *ty)
|
CastKind::FloatToInt | CastKind::FloatToFloat => {
|
||||||
.map(|result| ValueOrPlaceOrRef::Value(self.wrap_immediate(result, *ty)))
|
self.ecx.float_to_float_or_int(&op, *ty)
|
||||||
.unwrap_or(ValueOrPlaceOrRef::top()),
|
}
|
||||||
_ => ValueOrPlaceOrRef::top(),
|
_ => unreachable!(),
|
||||||
}
|
}
|
||||||
}
|
.map(|result| ValueOrPlaceOrRef::Value(self.wrap_immediate(result, *ty)))
|
||||||
|
.unwrap_or(ValueOrPlaceOrRef::top()),
|
||||||
|
_ => ValueOrPlaceOrRef::top(),
|
||||||
|
},
|
||||||
Rvalue::BinaryOp(op, box (left, right)) => {
|
Rvalue::BinaryOp(op, box (left, right)) => {
|
||||||
// Overflows must be ignored here.
|
// Overflows must be ignored here.
|
||||||
let (val, _overflow) = self.binary_op(state, *op, left, right);
|
let (val, _overflow) = self.binary_op(state, *op, left, right);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue