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"
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_base_name);
92  }
93 
94  void set_base_name(const irep_idt &base_name)
95  {
96  return set(ID_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_pretty_name);
112  }
113 
114  void set_pretty_name(const irep_idt &name)
115  {
116  return set(ID_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  optionalt<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 
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 
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 
449 {
450 public:
451  explicit struct_tag_typet(const irep_idt &identifier):
452  tag_typet(ID_struct_tag, identifier)
453  {
454  }
455 };
456 
460 template <>
461 inline bool can_cast_type<struct_tag_typet>(const typet &type)
462 {
463  return type.id() == ID_struct_tag;
464 }
465 
474 inline const struct_tag_typet &to_struct_tag_type(const typet &type)
475 {
477  return static_cast<const struct_tag_typet &>(type);
478 }
479 
482 {
484  return static_cast<struct_tag_typet &>(type);
485 }
486 
490 {
491 public:
492  enumeration_typet():typet(ID_enumeration)
493  {
494  }
495 
496  const irept::subt &elements() const
497  {
498  return find(ID_elements).get_sub();
499  }
500 
502  {
503  return add(ID_elements).get_sub();
504  }
505 };
506 
510 template <>
511 inline bool can_cast_type<enumeration_typet>(const typet &type)
512 {
513  return type.id() == ID_enumeration;
514 }
515 
524 inline const enumeration_typet &to_enumeration_type(const typet &type)
525 {
527  return static_cast<const enumeration_typet &>(type);
528 }
529 
532 {
534  return static_cast<enumeration_typet &>(type);
535 }
536 
538 class code_typet:public typet
539 {
540 public:
541  class parametert;
542  typedef std::vector<parametert> parameterst;
543 
547  code_typet(parameterst _parameters, typet _return_type) : typet(ID_code)
548  {
549  parameters().swap(_parameters);
550  return_type().swap(_return_type);
551  }
552 
553  // used to be argumentt -- now uses standard terminology
554 
555  class parametert:public exprt
556  {
557  public:
558  explicit parametert(const typet &type):exprt(ID_parameter, type)
559  {
560  }
561 
562  const exprt &default_value() const
563  {
564  return find_expr(ID_C_default_value);
565  }
566 
567  bool has_default_value() const
568  {
569  return default_value().is_not_nil();
570  }
571 
573  {
574  return add_expr(ID_C_default_value);
575  }
576 
577  // The following for methods will go away;
578  // these should not be part of the signature of a function,
579  // but rather part of the body.
580  void set_identifier(const irep_idt &identifier)
581  {
582  set(ID_C_identifier, identifier);
583  }
584 
585  void set_base_name(const irep_idt &name)
586  {
587  set(ID_C_base_name, name);
588  }
589 
590  const irep_idt &get_identifier() const
591  {
592  return get(ID_C_identifier);
593  }
594 
595  const irep_idt &get_base_name() const
596  {
597  return get(ID_C_base_name);
598  }
599 
600  bool get_this() const
601  {
602  return get_bool(ID_C_this);
603  }
604 
605  void set_this()
606  {
607  set(ID_C_this, true);
608  }
609  };
610 
611  bool has_ellipsis() const
612  {
613  return find(ID_parameters).get_bool(ID_ellipsis);
614  }
615 
616  bool has_this() const
617  {
618  return get_this() != nullptr;
619  }
620 
621  const parametert *get_this() const
622  {
623  const parameterst &p=parameters();
624  if(!p.empty() && p.front().get_this())
625  return &p.front();
626  else
627  return nullptr;
628  }
629 
630  bool is_KnR() const
631  {
632  return get_bool(ID_C_KnR);
633  }
634 
636  {
637  add(ID_parameters).set(ID_ellipsis, true);
638  }
639 
641  {
642  add(ID_parameters).remove(ID_ellipsis);
643  }
644 
645  const typet &return_type() const
646  {
647  return find_type(ID_return_type);
648  }
649 
651  {
652  return add_type(ID_return_type);
653  }
654 
655  const parameterst &parameters() const
656  {
657  return (const parameterst &)find(ID_parameters).get_sub();
658  }
659 
661  {
662  return (parameterst &)add(ID_parameters).get_sub();
663  }
664 
665  bool get_inlined() const
666  {
667  return get_bool(ID_C_inlined);
668  }
669 
670  void set_inlined(bool value)
671  {
672  set(ID_C_inlined, value);
673  }
674 
675  const irep_idt &get_access() const
676  {
677  return get(ID_access);
678  }
679 
680  void set_access(const irep_idt &access)
681  {
682  return set(ID_access, access);
683  }
684 
685  bool get_is_constructor() const
686  {
687  return get_bool(ID_constructor);
688  }
689 
691  {
692  set(ID_constructor, true);
693  }
694 
696  std::vector<irep_idt> parameter_identifiers() const
697  {
698  std::vector<irep_idt> result;
699  const parameterst &p=parameters();
700  result.reserve(p.size());
701  for(parameterst::const_iterator it=p.begin();
702  it!=p.end(); it++)
703  result.push_back(it->get_identifier());
704  return result;
705  }
706 
707  typedef std::unordered_map<irep_idt, std::size_t> parameter_indicest;
708 
711  {
713  const parameterst &params = parameters();
714  parameter_indices.reserve(params.size());
715  std::size_t index = 0;
716  for(const auto &p : params)
717  {
718  const irep_idt &id = p.get_identifier();
719  if(!id.empty())
720  parameter_indices.insert({ id, index });
721  ++index;
722  }
723  return parameter_indices;
724  }
725 };
726 
730 template <>
731 inline bool can_cast_type<code_typet>(const typet &type)
732 {
733  return type.id() == ID_code;
734 }
735 
744 inline const code_typet &to_code_type(const typet &type)
745 {
747  code_typet::check(type);
748  return static_cast<const code_typet &>(type);
749 }
750 
753 {
755  code_typet::check(type);
756  return static_cast<code_typet &>(type);
757 }
758 
763 {
764 public:
765  array_typet(typet _subtype, exprt _size)
766  : type_with_subtypet(ID_array, std::move(_subtype))
767  {
768  add(ID_size, std::move(_size));
769  }
770 
772  typet index_type() const;
773 
778  {
779  return static_cast<typet &>(add(ID_C_index_type));
780  }
781 
785  const typet &element_type() const
786  {
787  return subtype();
788  }
789 
794  {
795  return subtype();
796  }
797 
798  // We will eventually enforce that the type of the size
799  // is the same as the index type.
800  const exprt &size() const
801  {
802  return static_cast<const exprt &>(find(ID_size));
803  }
804 
805  // We will eventually enforce that the type of the size
806  // is the same as the index type.
808  {
809  return static_cast<exprt &>(add(ID_size));
810  }
811 
812  bool is_complete() const
813  {
814  return size().is_not_nil();
815  }
816 
817  bool is_incomplete() const
818  {
819  return size().is_nil();
820  }
821 
822  static void check(
823  const typet &type,
825 };
826 
830 template <>
831 inline bool can_cast_type<array_typet>(const typet &type)
832 {
833  return type.id() == ID_array;
834 }
835 
844 inline const array_typet &to_array_type(const typet &type)
845 {
847  array_typet::check(type);
848  return static_cast<const array_typet &>(type);
849 }
850 
853 {
855  array_typet::check(type);
856  return static_cast<array_typet &>(type);
857 }
858 
864 class bitvector_typet : public typet
865 {
866 public:
867  explicit bitvector_typet(const irep_idt &_id) : typet(_id)
868  {
869  }
870 
871  bitvector_typet(const irep_idt &_id, std::size_t width) : typet(_id)
872  {
873  set_width(width);
874  }
875 
876  std::size_t get_width() const
877  {
878  return get_size_t(ID_width);
879  }
880 
881  void set_width(std::size_t width)
882  {
883  set_size_t(ID_width, width);
884  }
885 
886  static void check(
887  const typet &type,
889  {
890  DATA_CHECK(
891  vm, !type.get(ID_width).empty(), "bitvector type must have width");
892  }
893 };
894 
898 template <>
899 inline bool can_cast_type<bitvector_typet>(const typet &type)
900 {
901  return type.id() == ID_signedbv || type.id() == ID_unsignedbv ||
902  type.id() == ID_fixedbv || type.id() == ID_floatbv ||
903  type.id() == ID_verilog_signedbv ||
904  type.id() == ID_verilog_unsignedbv || type.id() == ID_bv ||
905  type.id() == ID_pointer || type.id() == ID_c_bit_field ||
906  type.id() == ID_c_bool;
907 }
908 
912 class string_typet:public typet
913 {
914 public:
915  string_typet():typet(ID_string)
916  {
917  }
918 };
919 
923 template <>
924 inline bool can_cast_type<string_typet>(const typet &type)
925 {
926  return type.id() == ID_string;
927 }
928 
937 inline const string_typet &to_string_type(const typet &type)
938 {
940  return static_cast<const string_typet &>(type);
941 }
942 
945 {
947  return static_cast<string_typet &>(type);
948 }
949 
951 class range_typet:public typet
952 {
953 public:
954  range_typet(const mp_integer &_from, const mp_integer &_to) : typet(ID_range)
955  {
956  set_from(_from);
957  set_to(_to);
958  }
959 
960  mp_integer get_from() const;
961  mp_integer get_to() const;
962 
963  void set_from(const mp_integer &_from);
964  void set_to(const mp_integer &to);
965 };
966 
970 template <>
971 inline bool can_cast_type<range_typet>(const typet &type)
972 {
973  return type.id() == ID_range;
974 }
975 
984 inline const range_typet &to_range_type(const typet &type)
985 {
987  return static_cast<const range_typet &>(type);
988 }
989 
992 {
994  return static_cast<range_typet &>(type);
995 }
996 
1008 {
1009 public:
1011 
1013  typet index_type() const;
1014 
1019  {
1020  return static_cast<typet &>(add(ID_C_index_type));
1021  }
1022 
1026  const typet &element_type() const
1027  {
1028  return subtype();
1029  }
1030 
1035  {
1036  return subtype();
1037  }
1038 
1039  const constant_exprt &size() const;
1040  constant_exprt &size();
1041 };
1042 
1046 template <>
1047 inline bool can_cast_type<vector_typet>(const typet &type)
1048 {
1049  return type.id() == ID_vector;
1050 }
1051 
1060 inline const vector_typet &to_vector_type(const typet &type)
1061 {
1064  return static_cast<const vector_typet &>(type);
1065 }
1066 
1069 {
1072  return static_cast<vector_typet &>(type);
1073 }
1074 
1077 {
1078 public:
1079  explicit complex_typet(typet _subtype)
1080  : type_with_subtypet(ID_complex, std::move(_subtype))
1081  {
1082  }
1083 };
1084 
1088 template <>
1089 inline bool can_cast_type<complex_typet>(const typet &type)
1090 {
1091  return type.id() == ID_complex;
1092 }
1093 
1102 inline const complex_typet &to_complex_type(const typet &type)
1103 {
1106  return static_cast<const complex_typet &>(type);
1107 }
1108 
1111 {
1114  return static_cast<complex_typet &>(type);
1115 }
1116 
1118  const typet &type,
1119  const namespacet &ns);
1120 
1121 #endif // CPROVER_UTIL_STD_TYPES_H
tag_typet::get_identifier
const irep_idt & get_identifier() const
Definition: std_types.h:410
struct_union_typet::components
const componentst & components() const
Definition: std_types.h:147
array_typet::check
static void check(const typet &type, const validation_modet vm=validation_modet::INVARIANT)
Definition: std_types.cpp:19
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
code_typet::has_ellipsis
bool has_ellipsis() const
Definition: std_types.h:611
irept::get_size_t
std::size_t get_size_t(const irep_idt &name) const
Definition: irep.cpp:68
to_enumeration_type
const enumeration_typet & to_enumeration_type(const typet &type)
Cast a typet to a enumeration_typet.
Definition: std_types.h:524
struct_tag_typet::struct_tag_typet
struct_tag_typet(const irep_idt &identifier)
Definition: std_types.h:451
tag_typet::set_identifier
void set_identifier(const irep_idt &identifier)
Definition: std_types.h:405
DATA_CHECK
#define DATA_CHECK(vm, condition, message)
This macro takes a condition which denotes a well-formedness criterion on goto programs,...
Definition: validate.h:22
struct_typet::get_base
optionalt< baset > get_base(const irep_idt &id) const
Return the base with the given name, if exists.
Definition: std_types.cpp:103
class_typet::methodst
componentst methodst
Definition: std_types.h:333
array_typet::is_incomplete
bool is_incomplete() const
Definition: std_types.h:817
exprt::find_expr
const exprt & find_expr(const irep_idt &name) const
Definition: expr.h:287
class_typet
Class type.
Definition: std_types.h:324
mp_integer
BigInt mp_integer
Definition: smt_terms.h:17
struct_union_typet::componentt::get_anonymous
bool get_anonymous() const
Definition: std_types.h:119
struct_union_typet::componentt::componentt
componentt(const irep_idt &_name, typet _type)
Definition: std_types.h:73
mp_arith.h
struct_union_typet::componentt::componentt
componentt()=default
struct_union_typet::get_component
const componentt & get_component(const irep_idt &component_name) const
Get the reference to a component with given name.
Definition: std_types.cpp:63
code_typet::parametert::default_value
exprt & default_value()
Definition: std_types.h:572
to_struct_type
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
Definition: std_types.h:308
struct_union_typet::componentt::set_access
void set_access(const irep_idt &access)
Definition: std_types.h:104
enumeration_typet
An enumeration type, i.e., a type with elements (not to be confused with C enums)
Definition: std_types.h:489
struct_union_typet::componentt::set_anonymous
void set_anonymous(bool anonymous)
Definition: std_types.h:124
class_typet::is_abstract
bool is_abstract() const
Definition: std_types.h:358
to_struct_union_type
const struct_union_typet & to_struct_union_type(const typet &type)
Cast a typet to a struct_union_typet.
Definition: std_types.h:214
array_typet::is_complete
bool is_complete() const
Definition: std_types.h:812
typet
The type of an expression, extends irept.
Definition: type.h:28
code_typet::parameterst
std::vector< parametert > parameterst
Definition: std_types.h:541
tag_typet::tag_typet
tag_typet(const irep_idt &_id, const irep_idt &identifier)
Definition: std_types.h:398
to_class_type
const class_typet & to_class_type(const typet &type)
Cast a typet to a class_typet.
Definition: std_types.h:381
irept::find
const irept & find(const irep_idt &name) const
Definition: irep.cpp:106
struct_union_typet
Base type for structs and unions.
Definition: std_types.h:61
vector_typet::size
const constant_exprt & size() const
Definition: std_types.cpp:269
code_typet::parametert::set_identifier
void set_identifier(const irep_idt &identifier)
Definition: std_types.h:580
class_typet::static_members
static_memberst & static_members()
Definition: std_types.h:353
struct_typet::add_base
void add_base(const struct_tag_typet &base)
Add a base class/struct.
Definition: std_types.cpp:98
struct_typet::has_base
bool has_base(const irep_idt &id) const
Test whether id is a base class/struct.
Definition: std_types.h:285
empty_typet::empty_typet
empty_typet()
Definition: std_types.h:53
invariant.h
struct_typet::is_prefix_of
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:117
array_typet::element_type
typet & element_type()
The type of the elements of the array.
Definition: std_types.h:793
can_cast_type< complex_typet >
bool can_cast_type< complex_typet >(const typet &type)
Check whether a reference to a typet is a complex_typet.
Definition: std_types.h:1089
struct_union_typet::component_type
const typet & component_type(const irep_idt &component_name) const
Definition: std_types.cpp:76
exprt
Base class for all expressions.
Definition: expr.h:55
struct_union_typet::componentst
std::vector< componentt > componentst
Definition: std_types.h:140
struct_union_typet::componentt::get_access
const irep_idt & get_access() const
Definition: std_types.h:99
struct_tag_typet
A struct tag type, i.e., struct_typet with an identifier.
Definition: std_types.h:448
complex_typet
Complex numbers made of pair of given subtype.
Definition: std_types.h:1076
vector_typet::index_type_nonconst
typet & index_type_nonconst()
The type of any index expression into an instance of this type.
Definition: std_types.h:1018
vector_typet
The vector type.
Definition: std_types.h:1007
struct_union_typet::componentt::get_pretty_name
const irep_idt & get_pretty_name() const
Definition: std_types.h:109
bool_typet
The Boolean type.
Definition: std_types.h:35
struct_union_typet::make_incomplete
void make_incomplete()
A struct/union may be incomplete.
Definition: std_types.h:191
struct_union_typet::default_access
irep_idt default_access() const
Return the access specification for members where access has not been modified.
Definition: std_types.h:179
type_with_subtypet
Type with a single subtype.
Definition: type.h:164
code_typet::parameter_indicest
std::unordered_map< irep_idt, std::size_t > parameter_indicest
Definition: std_types.h:707
to_complex_type
const complex_typet & to_complex_type(const typet &type)
Cast a typet to a complex_typet.
Definition: std_types.h:1102
can_cast_type< enumeration_typet >
bool can_cast_type< enumeration_typet >(const typet &type)
Check whether a reference to a typet is a enumeration_typet.
Definition: std_types.h:511
struct_union_typet::component_number
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:46
code_typet::remove_ellipsis
void remove_ellipsis()
Definition: std_types.h:640
struct_union_typet::componentt::set_name
void set_name(const irep_idt &name)
Definition: std_types.h:84
code_typet::get_is_constructor
bool get_is_constructor() const
Definition: std_types.h:685
code_typet::get_this
const parametert * get_this() const
Definition: std_types.h:621
vector_typet::index_type
typet index_type() const
The type of any index expression into an instance of this type.
Definition: std_types.cpp:257
irept::get
const irep_idt & get(const irep_idt &name) const
Definition: irep.cpp:45
struct_union_typet::components
componentst & components()
Definition: std_types.h:152
expr.h
array_typet::size
const exprt & size() const
Definition: std_types.h:800
string_typet::string_typet
string_typet()
Definition: std_types.h:915
struct_union_typet::struct_union_typet
struct_union_typet(const irep_idt &_id)
Definition: std_types.h:64
namespacet
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:90
struct_union_typet::is_class
bool is_class() const
A struct may be a class, where members may have access restrictions.
Definition: std_types.h:172
can_cast_type< struct_typet >
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
exprt::type
typet & type()
Return the type of the expression.
Definition: expr.h:84
irept::is_not_nil
bool is_not_nil() const
Definition: irep.h:380
can_cast_type< code_typet >
bool can_cast_type< code_typet >(const typet &type)
Check whether a reference to a typet is a code_typet.
Definition: std_types.h:731
can_cast_type< vector_typet >
bool can_cast_type< vector_typet >(const typet &type)
Check whether a reference to a typet is a vector_typet.
Definition: std_types.h:1047
struct_union_typet::get_tag
irep_idt get_tag() const
Definition: std_types.h:168
to_code_type
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
Definition: std_types.h:744
struct_union_typet::struct_union_typet
struct_union_typet(const irep_idt &_id, componentst _components)
Definition: std_types.h:142
vector_typet::element_type
const typet & element_type() const
The type of the elements of the vector.
Definition: std_types.h:1026
class_typet::static_memberst
componentst static_memberst
Definition: std_types.h:346
code_typet::parametert::get_base_name
const irep_idt & get_base_name() const
Definition: std_types.h:595
to_tag_type
const tag_typet & to_tag_type(const typet &type)
Cast a typet to a tag_typet.
Definition: std_types.h:434
empty_typet
The empty type.
Definition: std_types.h:50
code_typet::get_access
const irep_idt & get_access() const
Definition: std_types.h:675
bitvector_typet::bitvector_typet
bitvector_typet(const irep_idt &_id, std::size_t width)
Definition: std_types.h:871
code_typet::parameter_identifiers
std::vector< irep_idt > parameter_identifiers() const
Produces the list of parameter identifiers.
Definition: std_types.h:696
struct_union_typet::componentt::get_name
const irep_idt & get_name() const
Definition: std_types.h:79
struct_union_typet::set_tag
void set_tag(const irep_idt &tag)
Definition: std_types.h:169
can_cast_type< struct_tag_typet >
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:461
code_typet::set_is_constructor
void set_is_constructor()
Definition: std_types.h:690
code_typet::parametert::default_value
const exprt & default_value() const
Definition: std_types.h:562
irept::set
void set(const irep_idt &name, const irep_idt &value)
Definition: irep.h:420
range_typet::get_from
mp_integer get_from() const
Definition: std_types.cpp:166
struct_typet::struct_typet
struct_typet(componentst _components)
Definition: std_types.h:237
complex_typet::complex_typet
complex_typet(typet _subtype)
Definition: std_types.h:1079
PRECONDITION
#define PRECONDITION(CONDITION)
Definition: invariant.h:463
struct_union_typet::componentt::get_is_padding
bool get_is_padding() const
Definition: std_types.h:129
struct_union_typet::componentt::set_pretty_name
void set_pretty_name(const irep_idt &name)
Definition: std_types.h:114
can_cast_type< array_typet >
bool can_cast_type< array_typet >(const typet &type)
Check whether a reference to a typet is a array_typet.
Definition: std_types.h:831
code_typet::code_typet
code_typet(parameterst _parameters, typet _return_type)
Constructs a new code type, i.e., function type.
Definition: std_types.h:547
struct_union_typet::componentt::set_base_name
void set_base_name(const irep_idt &base_name)
Definition: std_types.h:94
range_typet
A type for subranges of integers.
Definition: std_types.h:951
vector_typet::element_type
typet & element_type()
The type of the elements of the vector.
Definition: std_types.h:1034
code_typet::set_inlined
void set_inlined(bool value)
Definition: std_types.h:670
class_typet::static_members
const static_memberst & static_members() const
Definition: std_types.h:348
struct_typet::is_class
bool is_class() const
A struct may be a class, where members may have access restrictions.
Definition: std_types.h:245
struct_typet::bases
const basest & bases() const
Get the collection of base classes/structs.
Definition: std_types.h:262
bitvector_typet::bitvector_typet
bitvector_typet(const irep_idt &_id)
Definition: std_types.h:867
irept::swap
void swap(irept &irep)
Definition: irep.h:442
code_typet
Base type of functions.
Definition: std_types.h:538
struct_union_typet::has_component
bool has_component(const irep_idt &component_name) const
Definition: std_types.h:157
range_typet::get_to
mp_integer get_to() const
Definition: std_types.cpp:171
validation_modet
validation_modet
Definition: validation_mode.h:12
irept::is_nil
bool is_nil() const
Definition: irep.h:376
irept::id
const irep_idt & id() const
Definition: irep.h:396
struct_typet::basest
std::vector< baset > basest
Definition: std_types.h:259
to_struct_tag_type
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
Definition: std_types.h:474
array_typet::size
exprt & size()
Definition: std_types.h:807
dstringt::empty
bool empty() const
Definition: dstring.h:88
typet::add_type
typet & add_type(const irep_idt &name)
Definition: type.h:100
tag_typet
A tag-based type, i.e., typet with an identifier.
Definition: std_types.h:395
enumeration_typet::enumeration_typet
enumeration_typet()
Definition: std_types.h:492
irept::baset
tree_implementationt baset
Definition: irep.h:374
bitvector_typet::check
static void check(const typet &type, const validation_modet vm=validation_modet::INVARIANT)
Definition: std_types.h:886
code_typet::parameters
const parameterst & parameters() const
Definition: std_types.h:655
irept::set_size_t
void set_size_t(const irep_idt &name, const std::size_t value)
Definition: irep.cpp:87
typet::check
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:119
class_typet::methodt
componentt methodt
Definition: std_types.h:332
can_cast_type< string_typet >
bool can_cast_type< string_typet >(const typet &type)
Check whether a reference to a typet is a string_typet.
Definition: std_types.h:924
code_typet::parametert::get_this
bool get_this() const
Definition: std_types.h:600
optionalt
nonstd::optional< T > optionalt
Definition: optional.h:35
bitvector_typet::set_width
void set_width(std::size_t width)
Definition: std_types.h:881
struct_union_typet::componentt::set_is_padding
void set_is_padding(bool is_padding)
Definition: std_types.h:134
struct_typet::bases
basest & bases()
Get the collection of base classes/structs.
Definition: std_types.h:268
code_typet::has_this
bool has_this() const
Definition: std_types.h:616
range_typet::range_typet
range_typet(const mp_integer &_from, const mp_integer &_to)
Definition: std_types.h:954
sharing_treet< irept, forward_list_as_mapt< irep_idt, irept > >::subt
typename dt::subt subt
Definition: irep.h:160
code_typet::parametert::set_base_name
void set_base_name(const irep_idt &name)
Definition: std_types.h:585
code_typet::parametert::set_this
void set_this()
Definition: std_types.h:605
to_range_type
const range_typet & to_range_type(const typet &type)
Cast a typet to a range_typet.
Definition: std_types.h:984
bitvector_typet::get_width
std::size_t get_width() const
Definition: std_types.h:876
is_constant_or_has_constant_components
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:185
struct_union_typet::componentt
Definition: std_types.h:68
to_string_type
const string_typet & to_string_type(const typet &type)
Cast a typet to a string_typet.
Definition: std_types.h:937
enumeration_typet::elements
const irept::subt & elements() const
Definition: std_types.h:496
can_cast_type< bool_typet >
bool can_cast_type< bool_typet >(const typet &base)
Definition: std_types.h:44
range_typet::set_to
void set_to(const mp_integer &to)
Definition: std_types.cpp:161
struct_typet
Structure type, corresponds to C style structs.
Definition: std_types.h:230
struct_typet::struct_typet
struct_typet()
Definition: std_types.h:233
class_typet::methods
const methodst & methods() const
Definition: std_types.h:335
irept::add
irept & add(const irep_idt &name)
Definition: irep.cpp:116
array_typet
Arrays with given size.
Definition: std_types.h:762
exprt::add_expr
exprt & add_expr(const irep_idt &name)
Definition: expr.h:282
bitvector_typet
Base class of fixed-width bit-vector types.
Definition: std_types.h:864
code_typet::make_ellipsis
void make_ellipsis()
Definition: std_types.h:635
code_typet::parametert::parametert
parametert(const typet &type)
Definition: std_types.h:558
struct_typet::baset::type
struct_tag_typet & type()
Definition: std_types.cpp:83
array_typet::index_type_nonconst
typet & index_type_nonconst()
The type of the index expressions into any instance of this type.
Definition: std_types.h:777
can_cast_type< range_typet >
bool can_cast_type< range_typet >(const typet &type)
Check whether a reference to a typet is a range_typet.
Definition: std_types.h:971
string_typet
String type.
Definition: std_types.h:912
expr_cast.h
Templated functions to cast to specific exprt-derived classes.
code_typet::parametert::get_identifier
const irep_idt & get_identifier() const
Definition: std_types.h:590
irept::get_sub
subt & get_sub()
Definition: irep.h:456
to_array_type
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
Definition: std_types.h:844
code_typet::parametert
Definition: std_types.h:555
class_typet::class_typet
class_typet()
Definition: std_types.h:327
validate.h
code_typet::is_KnR
bool is_KnR() const
Definition: std_types.h:630
code_typet::get_inlined
bool get_inlined() const
Definition: std_types.h:665
typet::find_type
const typet & find_type(const irep_idt &name) const
Definition: type.h:105
type_with_subtypet::subtype
const typet & subtype() const
Definition: type.h:172
code_typet::return_type
typet & return_type()
Definition: std_types.h:650
to_vector_type
const vector_typet & to_vector_type(const typet &type)
Cast a typet to a vector_typet.
Definition: std_types.h:1060
code_typet::return_type
const typet & return_type() const
Definition: std_types.h:645
array_typet::array_typet
array_typet(typet _subtype, exprt _size)
Definition: std_types.h:765
bool_typet::bool_typet
bool_typet()
Definition: std_types.h:38
enumeration_typet::elements
irept::subt & elements()
Definition: std_types.h:501
irept::remove
void remove(const irep_idt &name)
Definition: irep.cpp:96
code_typet::parameter_indices
parameter_indicest parameter_indices() const
Get a map from parameter name to its index.
Definition: std_types.h:710
struct_union_typet::componentt::get_base_name
const irep_idt & get_base_name() const
Definition: std_types.h:89
can_cast_type< class_typet >
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
constant_exprt
A constant literal expression.
Definition: std_expr.h:2941
is_constant
bool is_constant(const typet &type)
This method tests, if the given typet is a constant.
Definition: std_types.h:29
class_typet::methods
methodst & methods()
Definition: std_types.h:340
array_typet::index_type
typet index_type() const
The type of the index expressions into any instance of this type.
Definition: std_types.cpp:33
struct_union_typet::is_incomplete
bool is_incomplete() const
A struct/union may be incomplete.
Definition: std_types.h:185
can_cast_type< tag_typet >
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
can_cast_type< struct_union_typet >
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
code_typet::set_access
void set_access(const irep_idt &access)
Definition: std_types.h:680
vector_typet::vector_typet
vector_typet(typet index_type, typet element_type, constant_exprt size)
Definition: std_types.cpp:247
irept::get_bool
bool get_bool(const irep_idt &name) const
Definition: irep.cpp:58
can_cast_type< bitvector_typet >
bool can_cast_type< bitvector_typet >(const typet &type)
Check whether a reference to a typet is a bitvector_typet.
Definition: std_types.h:899
type_with_subtypet::check
static void check(const typet &type, const validation_modet vm=validation_modet::INVARIANT)
Definition: type.h:184
validation_modet::INVARIANT
@ INVARIANT
code_typet::parameters
parameterst & parameters()
Definition: std_types.h:660
range_typet::set_from
void set_from(const mp_integer &_from)
Definition: std_types.cpp:156
code_typet::parametert::has_default_value
bool has_default_value() const
Definition: std_types.h:567
array_typet::element_type
const typet & element_type() const
The type of the elements of the array.
Definition: std_types.h:785
sharing_treet
Base class for tree-like data structures with sharing.
Definition: irep.h:156