Skip to content

Commit d67cf77

Browse files
authored
Merge pull request #3492 from tautschnig/remove-mm-conversion
Remove thin wrapper memory_model_conversion
2 parents 6e2acdb + 94b1fbb commit d67cf77

File tree

2 files changed

+10
-30
lines changed

2 files changed

+10
-30
lines changed

src/pointer-analysis/value_set_dereference.cpp

Lines changed: 10 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -536,52 +536,34 @@ bool value_set_dereferencet::memory_model(
536536
const typet from_type=value.type();
537537

538538
// first, check if it's really just a type coercion,
539-
// i.e., both have exactly the same (constant) size
539+
// i.e., both have exactly the same (constant) size,
540+
// for bit-vector types or pointers
540541

541-
if(is_a_bv_type(from_type) &&
542-
is_a_bv_type(to_type))
542+
if(
543+
(is_a_bv_type(from_type) && is_a_bv_type(to_type)) ||
544+
(from_type.id() == ID_pointer && to_type.id() == ID_pointer))
543545
{
544546
if(pointer_offset_bits(from_type, ns) == pointer_offset_bits(to_type, ns))
545547
{
546548
// avoid semantic conversion in case of
547549
// cast to float or fixed-point,
548550
// or cast from float or fixed-point
549551

550-
if(to_type.id()==ID_fixedbv || to_type.id()==ID_floatbv ||
551-
from_type.id()==ID_fixedbv || from_type.id()==ID_floatbv)
552+
if(
553+
to_type.id() != ID_fixedbv && to_type.id() != ID_floatbv &&
554+
from_type.id() != ID_fixedbv && from_type.id() != ID_floatbv)
552555
{
556+
value = typecast_exprt::conditional_cast(value, to_type);
557+
return true;
553558
}
554-
else
555-
return memory_model_conversion(value, to_type);
556559
}
557560
}
558561

559-
// we are willing to do the same for pointers
560-
561-
if(from_type.id()==ID_pointer &&
562-
to_type.id()==ID_pointer)
563-
{
564-
if(pointer_offset_bits(from_type, ns) == pointer_offset_bits(to_type, ns))
565-
return memory_model_conversion(value, to_type);
566-
}
567-
568562
// otherwise, we will stitch it together from bytes
569563

570564
return memory_model_bytes(value, to_type, offset);
571565
}
572566

573-
/// Make `value` into a typecast expression: `(to_type)value`
574-
/// \return true
575-
bool value_set_dereferencet::memory_model_conversion(
576-
exprt &value,
577-
const typet &to_type)
578-
{
579-
// only doing type conversion
580-
// just do the typecast
581-
value.make_typecast(to_type);
582-
return true;
583-
}
584-
585567
/// Replace `value` by an expression of type `to_type` corresponding to the
586568
/// value at memory address `value + offset`.
587569
///

src/pointer-analysis/value_set_dereference.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,6 @@ class value_set_dereferencet
9999

100100
bool memory_model(exprt &value, const typet &type, const exprt &offset);
101101

102-
bool memory_model_conversion(exprt &value, const typet &type);
103-
104102
bool memory_model_bytes(
105103
exprt &value,
106104
const typet &type,

0 commit comments

Comments
 (0)