Skip to content

Commit 3244212

Browse files
committed
Use pointer_offset_bits instead of locally hacking up what it does anyway
1 parent ed0348d commit 3244212

File tree

2 files changed

+4
-33
lines changed

2 files changed

+4
-33
lines changed

src/goto-programs/vcd_goto_trace.cpp

+2-17
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,7 @@ std::string as_vcd_binary(
6060

6161
// build "xxx"
6262

63-
mp_integer width;
64-
65-
if(type.id()==ID_unsignedbv ||
66-
type.id()==ID_signedbv ||
67-
type.id()==ID_floatbv ||
68-
type.id()==ID_fixedbv ||
69-
type.id()==ID_pointer ||
70-
type.id()==ID_bv)
71-
width=string2integer(type.get_string(ID_width));
72-
else
73-
width=pointer_offset_size(type, ns)*8;
63+
const mp_integer width = pointer_offset_bits(type, ns);
7464

7565
if(width>=0)
7666
return std::string(integer2size_t(width), 'x');
@@ -103,12 +93,7 @@ void output_vcd(
10393

10494
const auto number=n.number(identifier);
10595

106-
mp_integer width;
107-
108-
if(type.id()==ID_bool)
109-
width=1;
110-
else
111-
width=pointer_offset_bits(type, ns);
96+
const mp_integer width = pointer_offset_bits(type, ns);
11297

11398
if(width>=1)
11499
out << "$var reg " << width << " V" << number << " "

src/pointer-analysis/value_set_dereference.cpp

+2-16
Original file line numberDiff line numberDiff line change
@@ -702,20 +702,6 @@ void value_set_dereferencet::bounds_check(
702702
}
703703
}
704704

705-
inline static unsigned bv_width(
706-
const typet &type,
707-
const namespacet &ns)
708-
{
709-
if(type.id()==ID_c_enum_tag)
710-
{
711-
const typet &t=ns.follow_tag(to_c_enum_tag_type(type));
712-
assert(t.id()==ID_c_enum);
713-
return bv_width(t.subtype(), ns);
714-
}
715-
716-
return unsafe_string2unsigned(type.get_string(ID_width));
717-
}
718-
719705
static bool is_a_bv_type(const typet &type)
720706
{
721707
return type.id()==ID_unsignedbv ||
@@ -742,7 +728,7 @@ bool value_set_dereferencet::memory_model(
742728
if(is_a_bv_type(from_type) &&
743729
is_a_bv_type(to_type))
744730
{
745-
if(bv_width(from_type, ns)==bv_width(to_type, ns))
731+
if(pointer_offset_bits(from_type, ns) == pointer_offset_bits(to_type, ns))
746732
{
747733
// avoid semantic conversion in case of
748734
// cast to float or fixed-point,
@@ -762,7 +748,7 @@ bool value_set_dereferencet::memory_model(
762748
if(from_type.id()==ID_pointer &&
763749
to_type.id()==ID_pointer)
764750
{
765-
if(bv_width(from_type, ns)==bv_width(to_type, ns))
751+
if(pointer_offset_bits(from_type, ns) == pointer_offset_bits(to_type, ns))
766752
return memory_model_conversion(value, to_type, guard, offset);
767753
}
768754

0 commit comments

Comments
 (0)