Skip to content

Commit

Permalink
Merge pull request #8477 from diffblue/bitvector_width_biginteger
Browse files Browse the repository at this point in the history
`bitvector_typet`: set width from mp_integer
  • Loading branch information
kroening authored Sep 29, 2024
2 parents 4bd5c0a + 0079017 commit 83922b2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/ansi-c/c_typecheck_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1496,7 +1496,7 @@ void c_typecheck_baset::typecheck_c_bit_field_type(c_bit_field_typet &type)
<< "bit field width is negative";
}

type.set_width(numeric_cast_v<std::size_t>(i));
type.width(i);
type.remove(ID_size);
}

Expand Down
11 changes: 11 additions & 0 deletions src/util/std_types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Author: Daniel Kroening, kroening@kroening.com

#include "std_types.h"

#include "arith_tools.h"
#include "c_types.h"
#include "namespace.h"
#include "std_expr.h"
Expand Down Expand Up @@ -154,6 +155,16 @@ bool is_rvalue_reference(const typet &type)
type.get_bool(ID_C_rvalue_reference);
}

std::size_t bitvector_typet::width() const
{
return get_size_t(ID_width);
}

void bitvector_typet::width(const mp_integer &width)
{
set_width(numeric_cast_v<std::size_t>(width));
}

void range_typet::set_from(const mp_integer &from)
{
set(ID_from, integer2string(from));
Expand Down
9 changes: 9 additions & 0 deletions src/util/std_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -917,16 +917,25 @@ class bitvector_typet : public typet
set_width(width);
}

bitvector_typet(const irep_idt &_id, mp_integer _width) : typet(_id)
{
width(_width);
}

std::size_t get_width() const
{
return get_size_t(ID_width);
}

std::size_t width() const;

void set_width(std::size_t width)
{
set_size_t(ID_width, width);
}

void width(const mp_integer &);

static void check(
const typet &type,
const validation_modet vm = validation_modet::INVARIANT)
Expand Down

0 comments on commit 83922b2

Please sign in to comment.