32#include <unordered_set>
54 type = already_typechecked.
get_type();
56 c_qualifiers.
write(type);
140 "underlying type must be bitvector");
287 type =
result.with_source_location(type);
310 <<
"' applied to inappropriate type '" <<
to_string(type) <<
"'";
321 <<
"only a pointer can be 'restrict'";
339 <<
"failed to convert bit vector width to constant";
364 f_expr.find_source_location();
374 <<
"failed to convert number of fraction bits to constant";
380 <<
"fixedbv fraction width invalid";
394 f_expr.find_source_location();
404 <<
"failed to convert number of fraction bits to constant";
410 <<
"floatbv fraction width invalid";
429 if(parameters.empty())
467 if(identifier.
empty())
488 if(parameters.size() == 1 && parameters[0].type().id() ==
ID_empty)
506 <<
"function must not return array";
512 <<
"function must not return function type";
536 <<
"array has incomplete element type";
544 <<
"array of function element type";
571 <<
"failed to convert constant: " <<
tmp_size.pretty();
577 <<
"array size must not be negative, "
609 <<
"' is not constant";
629 assignment.
lhs()=symbol_expr;
630 assignment.
rhs() = new_symbol.
value;
665 <<
"cannot make a vector of subtype " <<
to_string(subtype);
674 <<
"failed to convert constant: " << size.
pretty();
680 <<
"vector size must be positive, "
691 <<
"failed to determine size of vector base type '" <<
to_string(subtype)
702 <<
"failed to determine size of vector base type '" <<
to_string(subtype)
709 <<
"type had size 0: '" <<
to_string(subtype) <<
"'";
716 <<
"vector size (" << s <<
") expected to be multiple of base type size ("
725 new_type.size().add_source_location() = source_location;
726 type =
new_type.with_source_location(source_location);
779 symbol_table_baset::symbolst::const_iterator
s_it =
813 s_it->second.type.id() == type.
id() &&
827 else if(
s_it->second.type.id() != type.
id())
830 <<
"redefinition of '" <<
s_it->second.pretty_name <<
"'"
831 <<
" as different kind of tag";
836 <<
"redefinition of body of '" <<
s_it->second.pretty_name <<
"'";
893 for(
const auto &declarator : declaration.
declarators())
896 declarator.get_base_name(), declaration.
full_type(declarator));
902 : declarator.source_location();
924 <<
"no members defined";
963 <<
"incomplete type not permitted here";
969 <<
"void-typed member not permitted";
978 <<
"zero-width bit-field with declarator not permitted";
989 for(
auto &member : components)
991 if(!member.get_name().empty())
995 member.set_anonymous(
true);
1001 std::unordered_set<irep_idt> members;
1003 for(
const auto &
c : components)
1005 if(!members.insert(
c.get_name()).second)
1008 <<
"duplicate member '" <<
c.get_name() <<
'\'';
1019 for(struct_union_typet::componentst::iterator
1020 it=components.begin();
1021 it!=components.end();
1030 if(type.
id()==
ID_struct && it!=--components.end())
1033 <<
"flexible struct member must be last member";
1053 for(struct_union_typet::componentst::iterator
1054 it=components.begin();
1055 it!=components.end();
1063 <<
"static_assert not supported in compound body";
1075 <<
"failed _Static_assert";
1082 it=components.erase(it);
1091 components.empty() &&
1095 <<
"C requires that a struct or union has at least one member";
1211 const typet &underlying_type =
1218 <<
"' is an invalid underlying type";
1224 mp_integer value=0, min_value=0, max_value=0;
1226 std::vector<c_enum_typet::c_enum_membert>
enum_members;
1248 else if(
tmp_v.is_false())
1257 <<
"enum is not a constant";
1273 if(value <
tmp.smallest() || value >
tmp.largest())
1276 <<
"enumerator value is not representable in the underlying type '"
1329 std::size_t width = underlying_type.
get_width();
1384 <<
"use of tag that does not match previous declaration";
1398 if(!base_name.
empty())
1401 <<
"redeclaration of enum tag";
1424 <<
"anonymous enum tag without members";
1430 warning() <<
"ignoring specification of underlying type for enum" <<
eom;
1440 symbol_table_baset::symbolst::const_iterator
s_it =
1451 <<
"use of tag that does not match previous declaration";
1490 <<
"failed to convert bit field width";
1496 <<
"bit field width is negative";
1529 <<
"bit field has incomplete enum type";
1537 <<
"bit field with non-integer type: " <<
to_string(underlying_type);
1543 <<
"bit field (" << i <<
" bits) larger than type (" <<
sub_width
1555 c_qualifiers.
read(type);
1557 const auto &as_expr = (
const exprt &)type;
1559 if(!as_expr.has_operands())
1581 c_qualifiers.
write(type);
1588 symbol_table_baset::symbolst::const_iterator
s_it =
1594 <<
"typedef symbol '" << identifier <<
"' not found";
1602 <<
"expected type symbol for typedef";
1613 c_qualifiers.
write(type);
ANSI-C Language Conversion.
ANSI-CC Language Type Checking.
ansi_c_declarationt & to_ansi_c_declaration(exprt &expr)
bool is_signed_or_unsigned_bitvector(const typet &type)
This method tests, if the given typet is a signed or unsigned bitvector.
const bitvector_typet & to_bitvector_type(const typet &type)
Cast a typet to a bitvector_typet.
const integer_bitvector_typet & to_integer_bitvector_type(const typet &type)
Cast a typet to an integer_bitvector_typet.
ANSI-C Language Type Checking.
already_typechecked_typet & to_already_typechecked_type(typet &type)
floatbv_typet float_type()
signedbv_typet signed_long_int_type()
signedbv_typet signed_char_type()
unsignedbv_typet unsigned_int_type()
unsignedbv_typet unsigned_long_long_int_type()
unsignedbv_typet unsigned_long_int_type()
signedbv_typet signed_int_type()
pointer_typet pointer_type(const typet &subtype)
unsignedbv_typet unsigned_char_type()
signedbv_typet signed_size_type()
signedbv_typet signed_long_long_int_type()
bitvector_typet c_index_type()
floatbv_typet double_type()
signedbv_typet signed_short_int_type()
unsignedbv_typet unsigned_short_int_type()
const c_bit_field_typet & to_c_bit_field_type(const typet &type)
Cast a typet to a c_bit_field_typet.
const c_enum_typet & to_c_enum_type(const typet &type)
Cast a typet to a c_enum_typet.
const c_enum_tag_typet & to_c_enum_tag_type(const typet &type)
Cast a typet to a c_enum_tag_typet.
const union_typet & to_union_type(const typet &type)
Cast a typet to a union_typet.
const union_tag_typet & to_union_tag_type(const typet &type)
Cast a typet to a union_tag_typet.
virtual void clear()
Reset the abstract state.
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
static void make_already_typechecked(typet &type)
const ansi_c_declaratort & declarator() const
const declaratorst & declarators() const
typet full_type(const ansi_c_declaratort &) const
bool get_is_static_assert() const
const exprt & size() const
const typet & element_type() const
The type of the elements of the array.
typet & index_type_nonconst()
The type of the index expressions into any instance of this type.
Base class of fixed-width bit-vector types.
std::size_t get_width() const
std::size_t width() const
Type for C bit fields These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (...
const typet & underlying_type() const
C enum tag type, i.e., c_enum_typet with an identifier.
void set_identifier(const irep_idt &identifier)
void set_value(const irep_idt &value)
void set_base_name(const irep_idt &base_name)
virtual void write(typet &src) const
virtual void read(const typet &src)
symbol_table_baset & symbol_table
virtual void typecheck_compound_body(struct_union_typet &type)
virtual void make_index_type(exprt &expr)
virtual void typecheck_code_type(code_typet &type)
virtual void typecheck_expr(exprt &expr)
void move_symbol(symbolt &symbol, symbolt *&new_symbol)
virtual void typecheck_vector_type(typet &type)
virtual void typecheck_c_enum_type(typet &type)
virtual void make_constant(exprt &expr)
virtual void typecheck_c_bit_field_type(c_bit_field_typet &type)
static void add_rounding_mode(exprt &)
std::list< codet > clean_code
virtual std::string to_string(const exprt &expr)
void typecheck_declaration(ansi_c_declarationt &)
virtual void typecheck_c_enum_tag_type(c_enum_tag_typet &type)
virtual void adjust_function_parameter(typet &type) const
typet enum_constant_type(const mp_integer &min, const mp_integer &max) const
virtual void typecheck_custom_type(typet &type)
const irep_idt const irep_idt mode
virtual void make_constant_index(exprt &expr)
bitvector_typet enum_underlying_type(const mp_integer &min, const mp_integer &max, bool is_packed) const
virtual void typecheck_compound_type(struct_union_typet &type)
virtual bool is_complete_type(const typet &type) const
id_type_mapt parameter_map
virtual void typecheck_typedef_type(typet &type)
virtual void typecheck_array_type(array_typet &type)
virtual void typecheck_typeof_type(typet &type)
virtual void typecheck_type(typet &type)
A codet representing an assignment in the program.
A codet representing the declaration of a local variable.
std::vector< parametert > parameterst
const parameterst & parameters() const
const typet & return_type() const
Complex numbers made of pair of given subtype.
struct configt::ansi_ct ansi_c
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
const source_locationt & find_source_location() const
Get a source_locationt from the expression or from its operands (non-recursively).
bool is_true() const
Return whether the expression is a constant representing true.
bool is_false() const
Return whether the expression is a constant representing false.
typet & type()
Return the type of the expression.
const source_locationt & source_location() const
source_locationt & add_source_location()
Unbounded, signed integers (mathematical integers, not bitvectors)
There are a large number of kinds of tree structured or tree-like data in CPROVER.
bool get_bool(const irep_idt &name) const
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
const irept & find(const irep_idt &name) const
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)
const irep_idt & id() const
irept & add(const irep_idt &name)
source_locationt source_location
message_handlert & get_message_handler()
mstreamt & warning() const
mstreamt & result() const
const union_typet & follow_tag(const union_tag_typet &) const
Follow type tag of union type.
Unbounded, signed rational numbers.
A struct tag type, i.e., struct_typet with an identifier.
Base type for structs and unions.
const componentst & components() const
std::vector< componentt > componentst
Expression to hold a symbol (variable)
symbolt & get_writeable_ref(const irep_idt &name)
Find a symbol in the symbol table for read-write access.
virtual symbolt * get_writeable(const irep_idt &name)=0
Find a symbol in the symbol table for read-write access.
const symbolst & symbols
Read-only field, used to look up symbols given their names.
source_locationt location
Source code location of definition of symbol.
class symbol_exprt symbol_expr() const
Produces a symbol_exprt for a symbol.
typet type
Type of symbol.
irep_idt name
The unique identifier.
irep_idt irep_idt base_name
Name of module the symbol belongs to.
exprt value
Initial value of symbol.
void set_identifier(const irep_idt &identifier)
Symbol table entry describing a data typeThis is a symbol generated as part of type checking.
Semantic type conversion.
static exprt conditional_cast(const exprt &expr, const typet &type)
errort with_location(source_locationt _location) &&
The type of an expression, extends irept.
typet & add_type(const irep_idt &name)
const typet & find_type(const irep_idt &name) const
source_locationt & add_source_location()
const source_locationt & source_location() const
typet && with_source_location(source_locationt location) &&
This is a 'fluent style' method for creating a new type with an added-on source location.
A union tag type, i.e., union_typet with an identifier.
symbolt & get_fresh_aux_symbol(const typet &type, const std::string &name_prefix, const std::string &basename_prefix, const source_locationt &source_location, const irep_idt &symbol_mode, const namespacet &ns, symbol_table_baset &symbol_table)
Installs a fresh-named symbol with respect to the given namespace ns with the requested name pattern ...
Fresh auxiliary symbol creation.
signedbv_typet gcc_signed_int128_type()
unsignedbv_typet gcc_unsigned_int128_type()
floatbv_typet gcc_float128_type()
const std::string & id2string(const irep_idt &d)
const mp_integer string2integer(const std::string &n, unsigned base)
const std::string integer2string(const mp_integer &n, unsigned base)
mp_integer alignment(const typet &type, const namespacet &ns)
void add_padding(struct_typet &type, const namespacet &ns)
ANSI-C Language Type Checking.
API to expression classes for Pointers.
const address_of_exprt & to_address_of_expr(const exprt &expr)
Cast an exprt to an address_of_exprt.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
std::optional< exprt > size_of_expr(const typet &type, const namespacet &ns)
bool simplify(exprt &expr, const namespacet &ns)
#define UNREACHABLE
This should be used to mark dead code.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
#define PRECONDITION(CONDITION)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
const binary_exprt & to_binary_expr(const exprt &expr)
Cast an exprt to a binary_exprt.
const unary_exprt & to_unary_expr(const exprt &expr)
Cast an exprt to a unary_exprt.
const constant_exprt & to_constant_expr(const exprt &expr)
Cast an exprt to a constant_exprt.
const code_typet & to_code_type(const typet &type)
Cast a typet to a code_typet.
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
const array_typet & to_array_type(const typet &type)
Cast a typet to an array_typet.
const struct_union_typet & to_struct_union_type(const typet &type)
Cast a typet to a struct_union_typet.
static std::string type2name(const typet &type, const namespacet &ns, symbol_numbert &symbol_number)
const type_with_subtypet & to_type_with_subtype(const typet &type)
const typedef_typet & to_typedef_type(const typet &type)
Cast a generic typet to a typedef_typet.
bool is_signed(const typet &t)
Convenience function – is the type signed?