Skip to content

Commit 83922b2

Browse files
authored
Merge pull request #8477 from diffblue/bitvector_width_biginteger
`bitvector_typet`: set width from mp_integer
2 parents 4bd5c0a + 0079017 commit 83922b2

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

src/ansi-c/c_typecheck_type.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1496,7 +1496,7 @@ void c_typecheck_baset::typecheck_c_bit_field_type(c_bit_field_typet &type)
14961496
<< "bit field width is negative";
14971497
}
14981498

1499-
type.set_width(numeric_cast_v<std::size_t>(i));
1499+
type.width(i);
15001500
type.remove(ID_size);
15011501
}
15021502

src/util/std_types.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Author: Daniel Kroening, [email protected]
1212

1313
#include "std_types.h"
1414

15+
#include "arith_tools.h"
1516
#include "c_types.h"
1617
#include "namespace.h"
1718
#include "std_expr.h"
@@ -154,6 +155,16 @@ bool is_rvalue_reference(const typet &type)
154155
type.get_bool(ID_C_rvalue_reference);
155156
}
156157

158+
std::size_t bitvector_typet::width() const
159+
{
160+
return get_size_t(ID_width);
161+
}
162+
163+
void bitvector_typet::width(const mp_integer &width)
164+
{
165+
set_width(numeric_cast_v<std::size_t>(width));
166+
}
167+
157168
void range_typet::set_from(const mp_integer &from)
158169
{
159170
set(ID_from, integer2string(from));

src/util/std_types.h

+9
Original file line numberDiff line numberDiff line change
@@ -917,16 +917,25 @@ class bitvector_typet : public typet
917917
set_width(width);
918918
}
919919

920+
bitvector_typet(const irep_idt &_id, mp_integer _width) : typet(_id)
921+
{
922+
width(_width);
923+
}
924+
920925
std::size_t get_width() const
921926
{
922927
return get_size_t(ID_width);
923928
}
924929

930+
std::size_t width() const;
931+
925932
void set_width(std::size_t width)
926933
{
927934
set_size_t(ID_width, width);
928935
}
929936

937+
void width(const mp_integer &);
938+
930939
static void check(
931940
const typet &type,
932941
const validation_modet vm = validation_modet::INVARIANT)

0 commit comments

Comments
 (0)