13 #ifndef CPROVER_UTIL_STD_TYPES_H
14 #define CPROVER_UTIL_STD_TYPES_H
22 #include <unordered_map>
46 return base.
id() == ID_bool;
86 return set(ID_name, name);
91 return get(ID_C_base_name);
96 return set(ID_C_base_name, base_name);
101 return get(ID_access);
106 return set(ID_access, access);
111 return get(ID_C_pretty_name);
116 return set(ID_C_pretty_name, name);
126 return set(ID_anonymous, anonymous);
136 return set(ID_C_is_padding, is_padding);
163 const irep_idt &component_name)
const;
174 return id() == ID_struct &&
get_bool(ID_C_class);
181 return is_class() ? ID_private : ID_public;
193 set(ID_incomplete,
true);
203 return type.
id() == ID_struct || type.
id() == ID_union;
297 return type.
id() == ID_struct;
329 set(ID_C_class,
true);
407 set(ID_identifier, identifier);
412 return get(ID_identifier);
422 return type.
id() == ID_c_enum_tag || type.
id() == ID_struct_tag ||
423 type.
id() == ID_union_tag;
437 return static_cast<const tag_typet &
>(type);
456 PRECONDITION(
id == ID_struct_tag ||
id == ID_union_tag);
466 return type.
id() == ID_struct_tag || type.
id() == ID_union_tag;
507 return type.
id() == ID_struct_tag;
557 return type.
id() == ID_enumeration;
618 return add_expr(ID_C_default_value);
626 set(ID_C_identifier, identifier);
631 set(ID_C_base_name, name);
636 return get(ID_C_identifier);
641 return get(ID_C_base_name);
651 set(ID_C_this,
true);
668 if(!p.empty() && p.front().get_this())
681 add(ID_parameters).
set(ID_ellipsis,
true);
716 set(ID_C_inlined, value);
721 return get(ID_access);
726 return set(ID_access, access);
736 set(ID_constructor,
true);
742 std::vector<irep_idt> result;
744 result.reserve(p.size());
745 for(parameterst::const_iterator it=p.begin();
747 result.push_back(it->get_identifier());
759 std::size_t index = 0;
760 for(
const auto &p : params)
762 const irep_idt &
id = p.get_identifier();
777 return type.
id() == ID_code;
812 add(ID_size, std::move(_size));
823 return static_cast<typet &
>(
add(ID_C_index_type));
842 return static_cast<const exprt &
>(
find(ID_size));
849 return static_cast<exprt &
>(
add(ID_size));
877 return type.
id() == ID_array;
930 std::size_t
width()
const;
944 vm, !type.
get(ID_width).
empty(),
"bitvector type must have width");
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;
979 return type.
id() == ID_string;
1026 return type.
id() == ID_range;
1073 return static_cast<typet &
>(
add(ID_C_index_type));
1102 return type.
id() == ID_vector;
1144 return type.
id() == ID_complex;
const typet & subtype() const
typet & element_type()
The type of the elements of the array.
static void check(const typet &type, const validation_modet vm=validation_modet::INVARIANT)
array_typet(typet _subtype, exprt _size)
bool is_incomplete() const
typet index_type() const
The type of the index expressions into any instance of this type.
typet & index_type_nonconst()
The type of the index expressions into any instance of this type.
const typet & element_type() const
The type of the elements of the array.
const exprt & size() const
Base class of fixed-width bit-vector types.
void set_width(std::size_t width)
std::size_t get_width() const
std::size_t width() const
static void check(const typet &type, const validation_modet vm=validation_modet::INVARIANT)
bitvector_typet(const irep_idt &_id, std::size_t width)
bitvector_typet(const irep_idt &_id, mp_integer _width)
bitvector_typet(const irep_idt &_id)
componentst static_memberst
const methodst & methods() const
static_memberst & static_members()
componentt static_membert
const static_memberst & static_members() const
const exprt & default_value() const
parametert(const typet &type)
void set_base_name(const irep_idt &name)
bool has_default_value() const
const irep_idt & get_base_name() const
const irep_idt & get_identifier() const
void set_identifier(const irep_idt &identifier)
code_typet(parameterst _parameters, typet _return_type)
Constructs a new code type, i.e., function type.
std::vector< parametert > parameterst
void set_is_constructor()
const typet & return_type() const
const irep_idt & get_access() const
void set_inlined(bool value)
std::vector< irep_idt > parameter_identifiers() const
Produces the list of parameter identifiers.
void set_access(const irep_idt &access)
parameterst & parameters()
std::unordered_map< irep_idt, std::size_t > parameter_indicest
const parametert * get_this() const
bool get_is_constructor() const
bool has_ellipsis() const
const parameterst & parameters() const
parameter_indicest parameter_indices() const
Get a map from parameter name to its index.
Complex numbers made of pair of given subtype.
complex_typet(typet _subtype)
A constant literal expression.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
An enumeration type, i.e., a type with elements (not to be confused with C enums)
const irept::subt & elements() const
Base class for all expressions.
exprt & add_expr(const irep_idt &name)
typet & type()
Return the type of the expression.
const exprt & find_expr(const irep_idt &name) const
bool get_bool(const irep_idt &name) const
std::size_t get_size_t(const irep_idt &name) const
const irept & find(const irep_idt &name) const
tree_implementationt baset
const irep_idt & get(const irep_idt &name) const
void remove(const irep_idt &name)
void set(const irep_idt &name, const irep_idt &value)
void set_size_t(const irep_idt &name, const std::size_t value)
const irep_idt & id() const
irept & add(const irep_idt &name)
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
A type for subranges of integers.
void set_to(const mp_integer &to)
void set_from(const mp_integer &_from)
mp_integer get_to() const
range_typet(const mp_integer &_from, const mp_integer &_to)
mp_integer get_from() const
Base class for tree-like data structures with sharing.
A struct or union tag type.
struct_or_union_tag_typet(const irep_idt &id, const irep_idt &identifier)
A struct tag type, i.e., struct_typet with an identifier.
struct_tag_typet(const irep_idt &identifier)
struct_tag_typet & type()
Structure type, corresponds to C style structs.
std::optional< baset > get_base(const irep_idt &id) const
Return the base with the given name, if exists.
basest & bases()
Get the collection of base classes/structs.
struct_typet(componentst _components)
bool has_base(const irep_idt &id) const
Test whether id is a base class/struct.
bool is_class() const
A struct may be a class, where members may have access restrictions.
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...
void add_base(const struct_tag_typet &base)
Add a base class/struct.
const basest & bases() const
Get the collection of base classes/structs.
std::vector< baset > basest
const irep_idt & get_name() const
bool get_anonymous() const
const irep_idt & get_base_name() const
void set_pretty_name(const irep_idt &name)
void set_anonymous(bool anonymous)
void set_base_name(const irep_idt &base_name)
const irep_idt & get_pretty_name() const
void set_is_padding(bool is_padding)
const irep_idt & get_access() const
bool get_is_padding() const
void set_access(const irep_idt &access)
void set_name(const irep_idt &name)
componentt(const irep_idt &_name, typet _type)
Base type for structs and unions.
const typet & component_type(const irep_idt &component_name) const
void set_tag(const irep_idt &tag)
bool is_class() const
A struct may be a class, where members may have access restrictions.
irep_idt default_access() const
Return the access specification for members where access has not been modified.
struct_union_typet(const irep_idt &_id)
const componentt & get_component(const irep_idt &component_name) const
Get the reference to a component with given name.
struct_union_typet(const irep_idt &_id, componentst _components)
bool has_component(const irep_idt &component_name) const
bool is_incomplete() const
A struct/union may be incomplete.
const componentst & components() const
void make_incomplete()
A struct/union may be incomplete.
std::size_t component_number(const irep_idt &component_name) const
Return the sequence number of the component with given name.
std::vector< componentt > componentst
componentst & components()
A tag-based type, i.e., typet with an identifier.
tag_typet(const irep_idt &_id, const irep_idt &identifier)
void set_identifier(const irep_idt &identifier)
const irep_idt & get_identifier() const
Type with a single subtype.
const typet & subtype() const
static void check(const typet &type, const validation_modet vm=validation_modet::INVARIANT)
The type of an expression, extends irept.
typet & add_type(const irep_idt &name)
const typet & find_type(const irep_idt &name) const
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)
vector_typet(typet index_type, typet element_type, constant_exprt size)
const typet & subtype() const
typet & index_type_nonconst()
The type of any index expression into an instance of this type.
const constant_exprt & size() const
typet & element_type()
The type of the elements of the vector.
const typet & element_type() const
The type of the elements of the vector.
typet index_type() const
The type of any index expression into an instance of this type.
Templated functions to cast to specific exprt-derived classes.
#define PRECONDITION(CONDITION)
const vector_typet & to_vector_type(const typet &type)
Cast a typet to a vector_typet.
bool can_cast_type< class_typet >(const typet &type)
Check whether a reference to a typet is a class_typet.
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.
const range_typet & to_range_type(const typet &type)
Cast a typet to a range_typet.
bool can_cast_type< bool_typet >(const typet &base)
const class_typet & to_class_type(const typet &type)
Cast a typet to a class_typet.
bool can_cast_type< complex_typet >(const typet &type)
Check whether a reference to a typet is a complex_typet.
bool can_cast_type< array_typet >(const typet &type)
Check whether a reference to a typet is a array_typet.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
bool can_cast_type< vector_typet >(const typet &type)
Check whether a reference to a typet is a vector_typet.
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.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
bool is_constant(const typet &type)
This method tests, if the given typet is a constant.
bool can_cast_type< struct_tag_typet >(const typet &type)
Check whether a reference to a typet is a struct_tag_typet.
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
const string_typet & to_string_type(const typet &type)
Cast a typet to a string_typet.
bool can_cast_type< code_typet >(const typet &type)
Check whether a reference to a typet is a code_typet.
const complex_typet & to_complex_type(const typet &type)
Cast a typet to a complex_typet.
const struct_union_typet & to_struct_union_type(const typet &type)
Cast a typet to a struct_union_typet.
bool can_cast_type< range_typet >(const typet &type)
Check whether a reference to a typet is a range_typet.
bool can_cast_type< tag_typet >(const typet &type)
Check whether a reference to a typet is a tag_typet.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
bool can_cast_type< enumeration_typet >(const typet &type)
Check whether a reference to a typet is a enumeration_typet.
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.
bool can_cast_type< bitvector_typet >(const typet &type)
Check whether a reference to a typet is a bitvector_typet.
const enumeration_typet & to_enumeration_type(const typet &type)
Cast a typet to a enumeration_typet.
bool can_cast_type< struct_union_typet >(const typet &type)
Check whether a reference to a typet is a struct_union_typet.
bool can_cast_type< string_typet >(const typet &type)
Check whether a reference to a typet is a string_typet.
bool can_cast_type< struct_typet >(const typet &type)
Check whether a reference to a typet is a struct_typet.
const tag_typet & to_tag_type(const typet &type)
Cast a typet to a tag_typet.
#define DATA_CHECK(vm, condition, message)
This macro takes a condition which denotes a well-formedness criterion on goto programs,...