CBMC
std_types.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Pre-defined types
4 
5 Author: Daniel Kroening, kroening@kroening.com
6  Maria Svorenova, maria.svorenova@diffblue.com
7 
8 \*******************************************************************/
9 
12 
13 #ifndef CPROVER_UTIL_STD_TYPES_H
14 #define CPROVER_UTIL_STD_TYPES_H
15 
16 #include "expr.h"
17 #include "expr_cast.h" // IWYU pragma: keep
18 #include "invariant.h"
19 #include "mp_arith.h"
20 #include "validate.h"
21 
22 #include <unordered_map>
23 
24 class constant_exprt;
25 class namespacet;
26 
29 inline bool is_constant(const typet &type)
30 {
31  return type.get_bool(ID_C_constant);
32 }
33 
35 class bool_typet:public typet
36 {
37 public:
38  bool_typet():typet(ID_bool)
39  {
40  }
41 };
42 
43 template <>
44 inline bool can_cast_type<bool_typet>(const typet &base)
45 {
46  return base.id() == ID_bool;
47 }
48 
50 class empty_typet:public typet
51 {
52 public:
53  empty_typet():typet(ID_empty)
54  {
55  }
56 };
57 
62 {
63 public:
64  explicit struct_union_typet(const irep_idt &_id):typet(_id)
65  {
66  }
67 
68  class componentt:public exprt
69  {
70  public:
71  componentt() = default;
72 
73  componentt(const irep_idt &_name, typet _type)
74  {
75  set_name(_name);
76  type().swap(_type);
77  }
78 
79  const irep_idt &get_name() const
80  {
81  return get(ID_name);
82  }
83 
84  void set_name(const irep_idt &name)
85  {
86  return set(ID_name, name);
87  }
88 
89  const irep_idt &get_base_name() const
90  {
91  return get(ID_C_base_name);
92  }
93 
94  void set_base_name(const irep_idt &base_name)
95  {
96  return set(ID_C_base_name, base_name);
97  }
98 
99  const irep_idt &get_access() const
100  {
101  return get(ID_access);
102  }
103 
104  void set_access(const irep_idt &access)
105  {
106  return set(ID_access, access);
107  }
108 
109  const irep_idt &get_pretty_name() const
110  {
111  return get(ID_C_pretty_name);
112  }
113 
114  void set_pretty_name(const irep_idt &name)
115  {
116  return set(ID_C_pretty_name, name);
117  }
118 
119  bool get_anonymous() const
120  {
121  return get_bool(ID_anonymous);
122  }
123 
124  void set_anonymous(bool anonymous)
125  {
126  return set(ID_anonymous, anonymous);
127  }
128 
129  bool get_is_padding() const
130  {
131  return get_bool(ID_C_is_padding);
132  }
133 
134  void set_is_padding(bool is_padding)
135  {
136  return set(ID_C_is_padding, is_padding);
137  }
138  };
139 
140  typedef std::vector<componentt> componentst;
141 
142  struct_union_typet(const irep_idt &_id, componentst _components) : typet(_id)
143  {
144  components() = std::move(_components);
145  }
146 
147  const componentst &components() const
148  {
149  return (const componentst &)(find(ID_components).get_sub());
150  }
151 
153  {
154  return (componentst &)(add(ID_components).get_sub());
155  }
156 
157  bool has_component(const irep_idt &component_name) const
158  {
159  return get_component(component_name).is_not_nil();
160  }
161 
162  const componentt &get_component(
163  const irep_idt &component_name) const;
164 
165  std::size_t component_number(const irep_idt &component_name) const;
166  const typet &component_type(const irep_idt &component_name) const;
167 
168  irep_idt get_tag() const { return get(ID_tag); }
169  void set_tag(const irep_idt &tag) { set(ID_tag, tag); }
170 
172  bool is_class() const
173  {
174  return id() == ID_struct && get_bool(ID_C_class);
175  }
176 
180  {
181  return is_class() ? ID_private : ID_public;
182  }
183 
185  bool is_incomplete() const
186  {
187  return get_bool(ID_incomplete);
188  }
189 
192  {
193  set(ID_incomplete, true);
194  }
195 };
196 
200 template <>
201 inline bool can_cast_type<struct_union_typet>(const typet &type)
202 {
203  return type.id() == ID_struct || type.id() == ID_union;
204 }
205 
215 {
217  return static_cast<const struct_union_typet &>(type);
218 }
219 
222 {
224  return static_cast<struct_union_typet &>(type);
225 }
226 
227 class struct_tag_typet;
228 
231 {
232 public:
234  {
235  }
236 
237  explicit struct_typet(componentst _components)
238  : struct_union_typet(ID_struct, std::move(_components))
239  {
240  }
241 
242  bool is_prefix_of(const struct_typet &other) const;
243 
245  bool is_class() const
246  {
247  return get_bool(ID_C_class);
248  }
249 
251  class baset : public exprt
252  {
253  public:
255  const struct_tag_typet &type() const;
256  explicit baset(struct_tag_typet base);
257  };
258 
259  typedef std::vector<baset> basest;
260 
262  const basest &bases() const
263  {
264  return (const basest &)find(ID_bases).get_sub();
265  }
266 
269  {
270  return (basest &)add(ID_bases).get_sub();
271  }
272 
275  void add_base(const struct_tag_typet &base);
276 
280  std::optional<baset> get_base(const irep_idt &id) const;
281 
285  bool has_base(const irep_idt &id) const
286  {
287  return get_base(id).has_value();
288  }
289 };
290 
294 template <>
295 inline bool can_cast_type<struct_typet>(const typet &type)
296 {
297  return type.id() == ID_struct;
298 }
299 
308 inline const struct_typet &to_struct_type(const typet &type)
309 {
311  return static_cast<const struct_typet &>(type);
312 }
313 
316 {
318  return static_cast<struct_typet &>(type);
319 }
320 
325 {
326 public:
328  {
329  set(ID_C_class, true);
330  }
331 
332  typedef componentt methodt;
334 
335  const methodst &methods() const
336  {
337  return (const methodst &)(find(ID_methods).get_sub());
338  }
339 
341  {
342  return (methodst &)(add(ID_methods).get_sub());
343  }
344 
345  using static_membert = componentt;
347 
349  {
350  return (const static_memberst &)(find(ID_static_members).get_sub());
351  }
352 
354  {
355  return (static_memberst &)(add(ID_static_members).get_sub());
356  }
357 
358  bool is_abstract() const
359  {
360  return get_bool(ID_abstract);
361  }
362 };
363 
367 template <>
368 inline bool can_cast_type<class_typet>(const typet &type)
369 {
370  return can_cast_type<struct_typet>(type) && type.get_bool(ID_C_class);
371 }
372 
381 inline const class_typet &to_class_type(const typet &type)
382 {
384  return static_cast<const class_typet &>(type);
385 }
386 
389 {
391  return static_cast<class_typet &>(type);
392 }
393 
395 class tag_typet:public typet
396 {
397 public:
398  explicit tag_typet(
399  const irep_idt &_id,
400  const irep_idt &identifier):typet(_id)
401  {
402  set_identifier(identifier);
403  }
404 
405  void set_identifier(const irep_idt &identifier)
406  {
407  set(ID_identifier, identifier);
408  }
409 
410  const irep_idt &get_identifier() const
411  {
412  return get(ID_identifier);
413  }
414 };
415 
419 template <>
420 inline bool can_cast_type<tag_typet>(const typet &type)
421 {
422  return type.id() == ID_c_enum_tag || type.id() == ID_struct_tag ||
423  type.id() == ID_union_tag;
424 }
425 
434 inline const tag_typet &to_tag_type(const typet &type)
435 {
437  return static_cast<const tag_typet &>(type);
438 }
439 
442 {
444  return static_cast<tag_typet &>(type);
445 }
446 
451 {
452 protected:
453  struct_or_union_tag_typet(const irep_idt &id, const irep_idt &identifier)
454  : tag_typet(id, identifier)
455  {
456  PRECONDITION(id == ID_struct_tag || id == ID_union_tag);
457  }
458 };
459 
463 template <>
465 {
466  return type.id() == ID_struct_tag || type.id() == ID_union_tag;
467 }
468 
477 inline const struct_or_union_tag_typet &
479 {
481  return static_cast<const struct_or_union_tag_typet &>(type);
482 }
483 
486 {
488  return static_cast<struct_or_union_tag_typet &>(type);
489 }
490 
493 {
494 public:
495  explicit struct_tag_typet(const irep_idt &identifier)
496  : struct_or_union_tag_typet(ID_struct_tag, identifier)
497  {
498  }
499 };
500 
504 template <>
505 inline bool can_cast_type<struct_tag_typet>(const typet &type)
506 {
507  return type.id() == ID_struct_tag;
508 }
509 
518 inline const struct_tag_typet &to_struct_tag_type(const typet &type)
519 {
521  return static_cast<const struct_tag_typet &>(type);
522 }
523 
526 {
528  return static_cast<struct_tag_typet &>(type);
529 }
530 
534 {
535 public:
536  enumeration_typet():typet(ID_enumeration)
537  {
538  }
539 
540  const irept::subt &elements() const
541  {
542  return find(ID_elements).get_sub();
543  }
544 
546  {
547  return add(ID_elements).get_sub();
548  }
549 };
550 
554 template <>
555 inline bool can_cast_type<enumeration_typet>(const typet &type)
556 {
557  return type.id() == ID_enumeration;
558 }
559 
568 inline const enumeration_typet &to_enumeration_type(const typet &type)
569 {
571  return static_cast<const enumeration_typet &>(type);
572 }
573 
576 {
578  return static_cast<enumeration_typet &>(type);
579 }
580 
582 class code_typet:public typet
583 {
584 public:
585  class parametert;
586  typedef std::vector<parametert> parameterst;
587 
591  code_typet(parameterst _parameters, typet _return_type) : typet(ID_code)
592  {
593  parameters().swap(_parameters);
594  return_type().swap(_return_type);
595  }
596 
597  // used to be argumentt -- now uses standard terminology
598 
599  class parametert:public exprt
600  {
601  public:
602  explicit parametert(const typet &type):exprt(ID_parameter, type)
603  {
604  }
605 
606  const exprt &default_value() const
607  {
608  return find_expr(ID_C_default_value);
609  }
610 
611  bool has_default_value() const
612  {
613  return default_value().is_not_nil();
614  }
615 
617  {
618  return add_expr(ID_C_default_value);
619  }
620 
621  // The following for methods will go away;
622  // these should not be part of the signature of a function,
623  // but rather part of the body.
624  void set_identifier(const irep_idt &identifier)
625  {
626  set(ID_C_identifier, identifier);
627  }
628 
629  void set_base_name(const irep_idt &name)
630  {
631  set(ID_C_base_name, name);
632  }
633 
634  const irep_idt &get_identifier() const
635  {
636  return get(ID_C_identifier);
637  }
638 
639  const irep_idt &get_base_name() const
640  {
641  return get(ID_C_base_name);
642  }
643 
644  bool get_this() const
645  {
646  return get_bool(ID_C_this);
647  }
648 
649  void set_this()
650  {
651  set(ID_C_this, true);
652  }
653  };
654 
655  bool has_ellipsis() const
656  {
657  return find(ID_parameters).get_bool(ID_ellipsis);
658  }
659 
660  bool has_this() const
661  {
662  return get_this() != nullptr;
663  }
664 
665  const parametert *get_this() const
666  {
667  const parameterst &p=parameters();
668  if(!p.empty() && p.front().get_this())
669  return &p.front();
670  else
671  return nullptr;
672  }
673 
674  bool is_KnR() const
675  {
676  return get_bool(ID_C_KnR);
677  }
678 
680  {
681  add(ID_parameters).set(ID_ellipsis, true);
682  }
683 
685  {
686  add(ID_parameters).remove(ID_ellipsis);
687  }
688 
689  const typet &return_type() const
690  {
691  return find_type(ID_return_type);
692  }
693 
695  {
696  return add_type(ID_return_type);
697  }
698 
699  const parameterst &parameters() const
700  {
701  return (const parameterst &)find(ID_parameters).get_sub();
702  }
703 
705  {
706  return (parameterst &)add(ID_parameters).get_sub();
707  }
708 
709  bool get_inlined() const
710  {
711  return get_bool(ID_C_inlined);
712  }
713 
714  void set_inlined(bool value)
715  {
716  set(ID_C_inlined, value);
717  }
718 
719  const irep_idt &get_access() const
720  {
721  return get(ID_access);
722  }
723 
724  void set_access(const irep_idt &access)
725  {
726  return set(ID_access, access);
727  }
728 
729  bool get_is_constructor() const
730  {
731  return get_bool(ID_constructor);
732  }
733 
735  {
736  set(ID_constructor, true);
737  }
738 
740  std::vector<irep_idt> parameter_identifiers() const
741  {
742  std::vector<irep_idt> result;
743  const parameterst &p=parameters();
744  result.reserve(p.size());
745  for(parameterst::const_iterator it=p.begin();
746  it!=p.end(); it++)
747  result.push_back(it->get_identifier());
748  return result;
749  }
750 
751  typedef std::unordered_map<irep_idt, std::size_t> parameter_indicest;
752 
755  {
757  const parameterst &params = parameters();
758  parameter_indices.reserve(params.size());
759  std::size_t index = 0;
760  for(const auto &p : params)
761  {
762  const irep_idt &id = p.get_identifier();
763  if(!id.empty())
764  parameter_indices.insert({ id, index });
765  ++index;
766  }
767  return parameter_indices;
768  }
769 };
770 
774 template <>
775 inline bool can_cast_type<code_typet>(const typet &type)
776 {
777  return type.id() == ID_code;
778 }
779 
788 inline const code_typet &to_code_type(const typet &type)
789 {
791  code_typet::check(type);
792  return static_cast<const code_typet &>(type);
793 }
794 
797 {
799  code_typet::check(type);
800  return static_cast<code_typet &>(type);
801 }
802 
807 {
808 public:
809  array_typet(typet _subtype, exprt _size)
810  : type_with_subtypet(ID_array, std::move(_subtype))
811  {
812  add(ID_size, std::move(_size));
813  }
814 
816  typet index_type() const;
817 
822  {
823  return static_cast<typet &>(add(ID_C_index_type));
824  }
825 
827  const typet &element_type() const
828  {
829  return subtype();
830  }
831 
834  {
835  return subtype();
836  }
837 
838  // We will eventually enforce that the type of the size
839  // is the same as the index type.
840  const exprt &size() const
841  {
842  return static_cast<const exprt &>(find(ID_size));
843  }
844 
845  // We will eventually enforce that the type of the size
846  // is the same as the index type.
848  {
849  return static_cast<exprt &>(add(ID_size));
850  }
851 
852  bool is_complete() const
853  {
854  return size().is_not_nil();
855  }
856 
857  bool is_incomplete() const
858  {
859  return size().is_nil();
860  }
861 
862  static void check(
863  const typet &type,
865 
866 protected:
867  // Use element_type() instead
869 };
870 
874 template <>
875 inline bool can_cast_type<array_typet>(const typet &type)
876 {
877  return type.id() == ID_array;
878 }
879 
888 inline const array_typet &to_array_type(const typet &type)
889 {
891  array_typet::check(type);
892  return static_cast<const array_typet &>(type);
893 }
894 
897 {
899  array_typet::check(type);
900  return static_cast<array_typet &>(type);
901 }
902 
908 class bitvector_typet : public typet
909 {
910 public:
911  explicit bitvector_typet(const irep_idt &_id) : typet(_id)
912  {
913  }
914 
915  bitvector_typet(const irep_idt &_id, std::size_t width) : typet(_id)
916  {
917  set_width(width);
918  }
919 
920  bitvector_typet(const irep_idt &_id, mp_integer _width) : typet(_id)
921  {
922  width(_width);
923  }
924 
925  std::size_t get_width() const
926  {
927  return get_size_t(ID_width);
928  }
929 
930  std::size_t width() const;
931 
932  void set_width(std::size_t width)
933  {
934  set_size_t(ID_width, width);
935  }
936 
937  void width(const mp_integer &);
938 
939  static void check(
940  const typet &type,
942  {
943  DATA_CHECK(
944  vm, !type.get(ID_width).empty(), "bitvector type must have width");
945  }
946 };
947 
951 template <>
952 inline bool can_cast_type<bitvector_typet>(const typet &type)
953 {
954  return type.id() == ID_signedbv || type.id() == ID_unsignedbv ||
955  type.id() == ID_fixedbv || type.id() == ID_floatbv ||
956  type.id() == ID_verilog_signedbv ||
957  type.id() == ID_verilog_unsignedbv || type.id() == ID_bv ||
958  type.id() == ID_pointer || type.id() == ID_c_bit_field ||
959  type.id() == ID_c_bool;
960 }
961 
965 class string_typet:public typet
966 {
967 public:
968  string_typet():typet(ID_string)
969  {
970  }
971 };
972 
976 template <>
977 inline bool can_cast_type<string_typet>(const typet &type)
978 {
979  return type.id() == ID_string;
980 }
981 
990 inline const string_typet &to_string_type(const typet &type)
991 {
993  return static_cast<const string_typet &>(type);
994 }
995 
998 {
1000  return static_cast<string_typet &>(type);
1001 }
1002 
1004 class range_typet:public typet
1005 {
1006 public:
1007  range_typet(const mp_integer &_from, const mp_integer &_to) : typet(ID_range)
1008  {
1009  set_from(_from);
1010  set_to(_to);
1011  }
1012 
1013  mp_integer get_from() const;
1014  mp_integer get_to() const;
1015 
1016  void set_from(const mp_integer &_from);
1017  void set_to(const mp_integer &to);
1018 };
1019 
1023 template <>
1024 inline bool can_cast_type<range_typet>(const typet &type)
1025 {
1026  return type.id() == ID_range;
1027 }
1028 
1037 inline const range_typet &to_range_type(const typet &type)
1038 {
1040  return static_cast<const range_typet &>(type);
1041 }
1042 
1045 {
1047  return static_cast<range_typet &>(type);
1048 }
1049 
1061 {
1062 public:
1064 
1066  typet index_type() const;
1067 
1072  {
1073  return static_cast<typet &>(add(ID_C_index_type));
1074  }
1075 
1077  const typet &element_type() const
1078  {
1079  return subtype();
1080  }
1081 
1084  {
1085  return subtype();
1086  }
1087 
1088  const constant_exprt &size() const;
1089  constant_exprt &size();
1090 
1091 protected:
1092  // Use element_type() instead
1094 };
1095 
1099 template <>
1100 inline bool can_cast_type<vector_typet>(const typet &type)
1101 {
1102  return type.id() == ID_vector;
1103 }
1104 
1113 inline const vector_typet &to_vector_type(const typet &type)
1114 {
1117  return static_cast<const vector_typet &>(type);
1118 }
1119 
1122 {
1125  return static_cast<vector_typet &>(type);
1126 }
1127 
1130 {
1131 public:
1132  explicit complex_typet(typet _subtype)
1133  : type_with_subtypet(ID_complex, std::move(_subtype))
1134  {
1135  }
1136 };
1137 
1141 template <>
1142 inline bool can_cast_type<complex_typet>(const typet &type)
1143 {
1144  return type.id() == ID_complex;
1145 }
1146 
1155 inline const complex_typet &to_complex_type(const typet &type)
1156 {
1159  return static_cast<const complex_typet &>(type);
1160 }
1161 
1164 {
1167  return static_cast<complex_typet &>(type);
1168 }
1169 
1171  const typet &type,
1172  const namespacet &ns);
1173 
1174 #endif // CPROVER_UTIL_STD_TYPES_H
Arrays with given size.
Definition: std_types.h:807
exprt & size()
Definition: std_types.h:847
const typet & subtype() const
Definition: type.h:187
typet & element_type()
The type of the elements of the array.
Definition: std_types.h:833
static void check(const typet &type, const validation_modet vm=validation_modet::INVARIANT)
Definition: std_types.cpp:20
array_typet(typet _subtype, exprt _size)
Definition: std_types.h:809
bool is_incomplete() const
Definition: std_types.h:857
typet index_type() const
The type of the index expressions into any instance of this type.
Definition: std_types.cpp:34
typet & index_type_nonconst()
The type of the index expressions into any instance of this type.
Definition: std_types.h:821
const typet & element_type() const
The type of the elements of the array.
Definition: std_types.h:827
bool is_complete() const
Definition: std_types.h:852
const exprt & size() const
Definition: std_types.h:840
Base class of fixed-width bit-vector types.
Definition: std_types.h:909
void set_width(std::size_t width)
Definition: std_types.h:932
std::size_t get_width() const
Definition: std_types.h:925
std::size_t width() const
Definition: std_types.cpp:158
static void check(const typet &type, const validation_modet vm=validation_modet::INVARIANT)
Definition: std_types.h:939
bitvector_typet(const irep_idt &_id, std::size_t width)
Definition: std_types.h:915
bitvector_typet(const irep_idt &_id, mp_integer _width)
Definition: std_types.h:920
bitvector_typet(const irep_idt &_id)
Definition: std_types.h:911
The Boolean type.
Definition: std_types.h:36
bool_typet()
Definition: std_types.h:38
Class type.
Definition: std_types.h:325
componentst methodst
Definition: std_types.h:333
componentst static_memberst
Definition: std_types.h:346
const methodst & methods() const
Definition: std_types.h:335
methodst & methods()
Definition: std_types.h:340
bool is_abstract() const
Definition: std_types.h:358
componentt methodt
Definition: std_types.h:332
static_memberst & static_members()
Definition: std_types.h:353
componentt static_membert
Definition: std_types.h:345
const static_memberst & static_members() const
Definition: std_types.h:348
const exprt & default_value() const
Definition: std_types.h:606
exprt & default_value()
Definition: std_types.h:616
parametert(const typet &type)
Definition: std_types.h:602
void set_base_name(const irep_idt &name)
Definition: std_types.h:629
bool get_this() const
Definition: std_types.h:644
bool has_default_value() const
Definition: std_types.h:611
const irep_idt & get_base_name() const
Definition: std_types.h:639
const irep_idt & get_identifier() const
Definition: std_types.h:634
void set_identifier(const irep_idt &identifier)
Definition: std_types.h:624
Base type of functions.
Definition: std_types.h:583
bool is_KnR() const
Definition: std_types.h:674
code_typet(parameterst _parameters, typet _return_type)
Constructs a new code type, i.e., function type.
Definition: std_types.h:591
std::vector< parametert > parameterst
Definition: std_types.h:585
void set_is_constructor()
Definition: std_types.h:734
const typet & return_type() const
Definition: std_types.h:689
const irep_idt & get_access() const
Definition: std_types.h:719
void set_inlined(bool value)
Definition: std_types.h:714
bool has_this() const
Definition: std_types.h:660
bool get_inlined() const
Definition: std_types.h:709
std::vector< irep_idt > parameter_identifiers() const
Produces the list of parameter identifiers.
Definition: std_types.h:740
void set_access(const irep_idt &access)
Definition: std_types.h:724
parameterst & parameters()
Definition: std_types.h:704
std::unordered_map< irep_idt, std::size_t > parameter_indicest
Definition: std_types.h:751
const parametert * get_this() const
Definition: std_types.h:665
bool get_is_constructor() const
Definition: std_types.h:729
void remove_ellipsis()
Definition: std_types.h:684
typet & return_type()
Definition: std_types.h:694
bool has_ellipsis() const
Definition: std_types.h:655
void make_ellipsis()
Definition: std_types.h:679
const parameterst & parameters() const
Definition: std_types.h:699
parameter_indicest parameter_indices() const
Get a map from parameter name to its index.
Definition: std_types.h:754
Complex numbers made of pair of given subtype.
Definition: std_types.h:1130
complex_typet(typet _subtype)
Definition: std_types.h:1132
A constant literal expression.
Definition: std_expr.h:2995
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
bool empty() const
Definition: dstring.h:89
The empty type.
Definition: std_types.h:51
An enumeration type, i.e., a type with elements (not to be confused with C enums)
Definition: std_types.h:534
const irept::subt & elements() const
Definition: std_types.h:540
irept::subt & elements()
Definition: std_types.h:545
Base class for all expressions.
Definition: expr.h:56
exprt & add_expr(const irep_idt &name)
Definition: expr.h:302
typet & type()
Return the type of the expression.
Definition: expr.h:84
const exprt & find_expr(const irep_idt &name) const
Definition: expr.h:307
bool get_bool(const irep_idt &name) const
Definition: irep.cpp:57
subt & get_sub()
Definition: irep.h:448
std::size_t get_size_t(const irep_idt &name) const
Definition: irep.cpp:67
const irept & find(const irep_idt &name) const
Definition: irep.cpp:93
tree_implementationt baset
Definition: irep.h:366
const irep_idt & get(const irep_idt &name) const
Definition: irep.cpp:44
void remove(const irep_idt &name)
Definition: irep.cpp:87
void set(const irep_idt &name, const irep_idt &value)
Definition: irep.h:412
void set_size_t(const irep_idt &name, const std::size_t value)
Definition: irep.cpp:82
bool is_not_nil() const
Definition: irep.h:372
const irep_idt & id() const
Definition: irep.h:388
void swap(irept &irep)
Definition: irep.h:434
irept & add(const irep_idt &name)
Definition: irep.cpp:103
bool is_nil() const
Definition: irep.h:368
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:94
A type for subranges of integers.
Definition: std_types.h:1005
void set_to(const mp_integer &to)
Definition: std_types.cpp:173
void set_from(const mp_integer &_from)
Definition: std_types.cpp:168
mp_integer get_to() const
Definition: std_types.cpp:183
range_typet(const mp_integer &_from, const mp_integer &_to)
Definition: std_types.h:1007
mp_integer get_from() const
Definition: std_types.cpp:178
Base class for tree-like data structures with sharing.
Definition: irep.h:149
String type.
Definition: std_types.h:966
A struct or union tag type.
Definition: std_types.h:451
struct_or_union_tag_typet(const irep_idt &id, const irep_idt &identifier)
Definition: std_types.h:453
A struct tag type, i.e., struct_typet with an identifier.
Definition: std_types.h:493
struct_tag_typet(const irep_idt &identifier)
Definition: std_types.h:495
struct_tag_typet & type()
Definition: std_types.cpp:84
Structure type, corresponds to C style structs.
Definition: std_types.h:231
std::optional< baset > get_base(const irep_idt &id) const
Return the base with the given name, if exists.
Definition: std_types.cpp:105
basest & bases()
Get the collection of base classes/structs.
Definition: std_types.h:268
struct_typet(componentst _components)
Definition: std_types.h:237
bool has_base(const irep_idt &id) const
Test whether id is a base class/struct.
Definition: std_types.h:285
bool is_class() const
A struct may be a class, where members may have access restrictions.
Definition: std_types.h:245
bool is_prefix_of(const struct_typet &other) const
Returns true if the struct is a prefix of other, i.e., if this struct has n components then the compo...
Definition: std_types.cpp:119
void add_base(const struct_tag_typet &base)
Add a base class/struct.
Definition: std_types.cpp:99
const basest & bases() const
Get the collection of base classes/structs.
Definition: std_types.h:262
std::vector< baset > basest
Definition: std_types.h:259
const irep_idt & get_name() const
Definition: std_types.h:79
const irep_idt & get_base_name() const
Definition: std_types.h:89
void set_pretty_name(const irep_idt &name)
Definition: std_types.h:114
void set_anonymous(bool anonymous)
Definition: std_types.h:124
void set_base_name(const irep_idt &base_name)
Definition: std_types.h:94
const irep_idt & get_pretty_name() const
Definition: std_types.h:109
void set_is_padding(bool is_padding)
Definition: std_types.h:134
const irep_idt & get_access() const
Definition: std_types.h:99
void set_access(const irep_idt &access)
Definition: std_types.h:104
void set_name(const irep_idt &name)
Definition: std_types.h:84
componentt(const irep_idt &_name, typet _type)
Definition: std_types.h:73
Base type for structs and unions.
Definition: std_types.h:62
const typet & component_type(const irep_idt &component_name) const
Definition: std_types.cpp:77
void set_tag(const irep_idt &tag)
Definition: std_types.h:169
irep_idt get_tag() const
Definition: std_types.h:168
bool is_class() const
A struct may be a class, where members may have access restrictions.
Definition: std_types.h:172
irep_idt default_access() const
Return the access specification for members where access has not been modified.
Definition: std_types.h:179
struct_union_typet(const irep_idt &_id)
Definition: std_types.h:64
const componentt & get_component(const irep_idt &component_name) const
Get the reference to a component with given name.
Definition: std_types.cpp:64
struct_union_typet(const irep_idt &_id, componentst _components)
Definition: std_types.h:142
bool has_component(const irep_idt &component_name) const
Definition: std_types.h:157
bool is_incomplete() const
A struct/union may be incomplete.
Definition: std_types.h:185
const componentst & components() const
Definition: std_types.h:147
void make_incomplete()
A struct/union may be incomplete.
Definition: std_types.h:191
std::size_t component_number(const irep_idt &component_name) const
Return the sequence number of the component with given name.
Definition: std_types.cpp:47
std::vector< componentt > componentst
Definition: std_types.h:140
componentst & components()
Definition: std_types.h:152
A tag-based type, i.e., typet with an identifier.
Definition: std_types.h:396
tag_typet(const irep_idt &_id, const irep_idt &identifier)
Definition: std_types.h:398
void set_identifier(const irep_idt &identifier)
Definition: std_types.h:405
const irep_idt & get_identifier() const
Definition: std_types.h:410
Type with a single subtype.
Definition: type.h:180
const typet & subtype() const
Definition: type.h:187
static void check(const typet &type, const validation_modet vm=validation_modet::INVARIANT)
Definition: type.h:199
The type of an expression, extends irept.
Definition: type.h:29
typet & add_type(const irep_idt &name)
Definition: type.h:115
const typet & find_type(const irep_idt &name) const
Definition: type.h:120
static void check(const typet &, const validation_modet=validation_modet::INVARIANT)
Check that the type is well-formed (shallow checks only, i.e., subtypes are not checked)
Definition: type.h:134
The vector type.
Definition: std_types.h:1061
vector_typet(typet index_type, typet element_type, constant_exprt size)
Definition: std_types.cpp:264
const typet & subtype() const
Definition: type.h:187
typet & index_type_nonconst()
The type of any index expression into an instance of this type.
Definition: std_types.h:1071
const constant_exprt & size() const
Definition: std_types.cpp:286
typet & element_type()
The type of the elements of the vector.
Definition: std_types.h:1083
const typet & element_type() const
The type of the elements of the vector.
Definition: std_types.h:1077
typet index_type() const
The type of any index expression into an instance of this type.
Definition: std_types.cpp:274
Templated functions to cast to specific exprt-derived classes.
BigInt mp_integer
Definition: smt_terms.h:17
#define PRECONDITION(CONDITION)
Definition: invariant.h:463
const vector_typet & to_vector_type(const typet &type)
Cast a typet to a vector_typet.
Definition: std_types.h:1113
bool can_cast_type< class_typet >(const typet &type)
Check whether a reference to a typet is a class_typet.
Definition: std_types.h:368
bool is_constant_or_has_constant_components(const typet &type, const namespacet &ns)
Identify whether a given type is constant itself or contains constant components.
Definition: std_types.cpp:197
const range_typet & to_range_type(const typet &type)
Cast a typet to a range_typet.
Definition: std_types.h:1037
bool can_cast_type< bool_typet >(const typet &base)
Definition: std_types.h:44
const class_typet & to_class_type(const typet &type)
Cast a typet to a class_typet.
Definition: std_types.h:381
bool can_cast_type< complex_typet >(const typet &type)
Check whether a reference to a typet is a complex_typet.
Definition: std_types.h:1142
bool can_cast_type< array_typet >(const typet &type)
Check whether a reference to a typet is a array_typet.
Definition: std_types.h:875
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
Definition: std_types.h:308
bool can_cast_type< vector_typet >(const typet &type)
Check whether a reference to a typet is a vector_typet.
Definition: std_types.h:1100
bool can_cast_type< struct_or_union_tag_typet >(const typet &type)
Check whether a reference to a typet is a struct_or_union_tag_typet.
Definition: std_types.h:464
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
Definition: std_types.h:788
bool is_constant(const typet &type)
This method tests, if the given typet is a constant.
Definition: std_types.h:29
bool can_cast_type< struct_tag_typet >(const typet &type)
Check whether a reference to a typet is a struct_tag_typet.
Definition: std_types.h:505
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
Definition: std_types.h:888
const string_typet & to_string_type(const typet &type)
Cast a typet to a string_typet.
Definition: std_types.h:990
bool can_cast_type< code_typet >(const typet &type)
Check whether a reference to a typet is a code_typet.
Definition: std_types.h:775
const complex_typet & to_complex_type(const typet &type)
Cast a typet to a complex_typet.
Definition: std_types.h:1155
const struct_union_typet & to_struct_union_type(const typet &type)
Cast a typet to a struct_union_typet.
Definition: std_types.h:214
bool can_cast_type< range_typet >(const typet &type)
Check whether a reference to a typet is a range_typet.
Definition: std_types.h:1024
bool can_cast_type< tag_typet >(const typet &type)
Check whether a reference to a typet is a tag_typet.
Definition: std_types.h:420
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
Definition: std_types.h:518
bool can_cast_type< enumeration_typet >(const typet &type)
Check whether a reference to a typet is a enumeration_typet.
Definition: std_types.h:555
const struct_or_union_tag_typet & to_struct_or_union_tag_type(const typet &type)
Cast a typet to a struct_or_union_tag_typet.
Definition: std_types.h:478
bool can_cast_type< bitvector_typet >(const typet &type)
Check whether a reference to a typet is a bitvector_typet.
Definition: std_types.h:952
const enumeration_typet & to_enumeration_type(const typet &type)
Cast a typet to a enumeration_typet.
Definition: std_types.h:568
bool can_cast_type< struct_union_typet >(const typet &type)
Check whether a reference to a typet is a struct_union_typet.
Definition: std_types.h:201
bool can_cast_type< string_typet >(const typet &type)
Check whether a reference to a typet is a string_typet.
Definition: std_types.h:977
bool can_cast_type< struct_typet >(const typet &type)
Check whether a reference to a typet is a struct_typet.
Definition: std_types.h:295
const tag_typet & to_tag_type(const typet &type)
Cast a typet to a tag_typet.
Definition: std_types.h:434
#define DATA_CHECK(vm, condition, message)
This macro takes a condition which denotes a well-formedness criterion on goto programs,...
Definition: validate.h:22
validation_modet