cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
c_bit_field_replacement_type.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module:
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
9
#include "
c_bit_field_replacement_type.h
"
10
11
#include <
util/c_types.h
>
12
#include <
util/invariant.h
>
13
#include <
util/namespace.h
>
14
15
typet
c_bit_field_replacement_type
(
16
const
c_bit_field_typet
&src,
17
const
namespacet
&ns)
18
{
19
const
typet
&underlying_type = src.
underlying_type
();
20
21
if
(
22
underlying_type.
id
() == ID_unsignedbv ||
23
underlying_type.
id
() == ID_signedbv || underlying_type.
id
() == ID_c_bool)
24
{
25
bitvector_typet
result =
to_bitvector_type
(underlying_type);
26
result.
set_width
(src.
get_width
());
27
return
std::move(result);
28
}
29
else
30
{
31
PRECONDITION
(underlying_type.
id
() == ID_c_enum_tag);
32
33
const
typet
&sub_subtype =
34
ns.
follow_tag
(
to_c_enum_tag_type
(underlying_type)).underlying_type();
35
36
PRECONDITION
(
37
sub_subtype.
id
() == ID_signedbv || sub_subtype.
id
() == ID_unsignedbv);
38
39
bitvector_typet
result =
to_bitvector_type
(sub_subtype);
40
result.
set_width
(src.
get_width
());
41
return
std::move(result);
42
}
43
}
to_bitvector_type
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a typet to a bitvector_typet.
Definition
bitvector_types.h:32
c_bit_field_replacement_type
typet c_bit_field_replacement_type(const c_bit_field_typet &src, const namespacet &ns)
Definition
c_bit_field_replacement_type.cpp:15
c_bit_field_replacement_type.h
c_types.h
to_c_enum_tag_type
const c_enum_tag_typet & to_c_enum_tag_type(const typet &type)
Cast a typet to a c_enum_tag_typet.
Definition
c_types.h:377
bitvector_typet
Base class of fixed-width bit-vector types.
Definition
std_types.h:909
bitvector_typet::set_width
void set_width(std::size_t width)
Definition
std_types.h:932
bitvector_typet::get_width
std::size_t get_width() const
Definition
std_types.h:925
c_bit_field_typet
Type for C bit fields These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (...
Definition
c_types.h:20
c_bit_field_typet::underlying_type
const typet & underlying_type() const
Definition
c_types.h:30
irept::id
const irep_idt & id() const
Definition
irep.h:388
namespace_baset::follow_tag
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
Definition
namespace.cpp:49
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition
namespace.h:91
typet
The type of an expression, extends irept.
Definition
type.h:29
namespace.h
invariant.h
PRECONDITION
#define PRECONDITION(CONDITION)
Definition
invariant.h:463
solvers
flattening
c_bit_field_replacement_type.cpp
Generated by
1.17.0