Skip to content

Commit 4de1e82

Browse files
committed
Use pointer_offset_bits instead of locally hacking up what it does anyway
1 parent 6a7fbfd commit 4de1e82

File tree

2 files changed

+4
-33
lines changed

2 files changed

+4
-33
lines changed

src/goto-programs/vcd_goto_trace.cpp

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -63,17 +63,7 @@ std::string as_vcd_binary(
6363

6464
// build "xxx"
6565

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

7868
if(width>=0)
7969
return std::string(integer2size_t(width), 'x');
@@ -106,12 +96,7 @@ void output_vcd(
10696

10797
const auto number=n.number(identifier);
10898

109-
mp_integer width;
110-
111-
if(type.id()==ID_bool)
112-
width=1;
113-
else
114-
width=pointer_offset_bits(type, ns);
99+
const mp_integer width = pointer_offset_bits(type, ns);
115100

116101
if(width>=1)
117102
out << "$var reg " << width << " V" << number << " "

src/pointer-analysis/value_set_dereference.cpp

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -712,20 +712,6 @@ void value_set_dereferencet::bounds_check(
712712
}
713713
}
714714

715-
inline static unsigned bv_width(
716-
const typet &type,
717-
const namespacet &ns)
718-
{
719-
if(type.id()==ID_c_enum_tag)
720-
{
721-
const typet &t=ns.follow_tag(to_c_enum_tag_type(type));
722-
assert(t.id()==ID_c_enum);
723-
return bv_width(t.subtype(), ns);
724-
}
725-
726-
return unsafe_string2unsigned(type.get_string(ID_width));
727-
}
728-
729715
static bool is_a_bv_type(const typet &type)
730716
{
731717
return type.id()==ID_unsignedbv ||
@@ -752,7 +738,7 @@ bool value_set_dereferencet::memory_model(
752738
if(is_a_bv_type(from_type) &&
753739
is_a_bv_type(to_type))
754740
{
755-
if(bv_width(from_type, ns)==bv_width(to_type, ns))
741+
if(pointer_offset_bits(from_type, ns) == pointer_offset_bits(to_type, ns))
756742
{
757743
// avoid semantic conversion in case of
758744
// cast to float or fixed-point,
@@ -772,7 +758,7 @@ bool value_set_dereferencet::memory_model(
772758
if(from_type.id()==ID_pointer &&
773759
to_type.id()==ID_pointer)
774760
{
775-
if(bv_width(from_type, ns)==bv_width(to_type, ns))
761+
if(pointer_offset_bits(from_type, ns) == pointer_offset_bits(to_type, ns))
776762
return memory_model_conversion(value, to_type, guard, offset);
777763
}
778764

0 commit comments

Comments
 (0)