cprover
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 
11 
13  const c_bit_field_typet &src,
14  const namespacet &ns)
15 {
16  const typet &subtype=src.subtype();
17 
18  if(subtype.id()==ID_unsignedbv ||
19  subtype.id()==ID_signedbv ||
20  subtype.id()==ID_c_bool)
21  {
22  bitvector_typet result=to_bitvector_type(subtype);
23  result.set_width(src.get_width());
24  return result;
25  }
26  else if(subtype.id()==ID_c_enum_tag)
27  {
28  const typet &sub_subtype=
29  ns.follow_tag(to_c_enum_tag_type(subtype)).subtype();
30 
31  if(sub_subtype.id()==ID_signedbv ||
32  sub_subtype.id()==ID_unsignedbv)
33  {
34  bitvector_typet result=to_bitvector_type(sub_subtype);
35  result.set_width(src.get_width());
36  return result;
37  }
38  else
39  return nil_typet();
40  }
41  else
42  return nil_typet();
43 }
The type of an expression.
Definition: type.h:22
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a generic typet to a bitvector_typet.
Definition: std_types.h:1150
typet c_bit_field_replacement_type(const c_bit_field_typet &src, const namespacet &ns)
const typet & follow_tag(const union_tag_typet &) const
Definition: namespace.cpp:74
Type for c bit fields.
Definition: std_types.h:1381
const irep_idt & id() const
Definition: irep.h:189
TO_BE_DOCUMENTED.
Definition: namespace.h:74
Base class of bitvector types.
Definition: std_types.h:1102
std::size_t get_width() const
Definition: std_types.h:1129
const c_enum_tag_typet & to_c_enum_tag_type(const typet &type)
Cast a generic typet to a c_enum_tag_typet.
Definition: std_types.h:747
The NIL type.
Definition: std_types.h:44
const typet & subtype() const
Definition: type.h:33
void set_width(std::size_t width)
Definition: std_types.h:1134