12 #ifndef CPROVER_CPP_CPP_TYPECHECK_H
13 #define CPROVER_CPP_CPP_TYPECHECK_H
26 #include <unordered_set>
34 const std::string &module,
48 const std::string &_module,
55 const std::string &_module,
75 bool fail_with_exception=
true)
78 return cpp_typecheck_resolve.
resolve(
79 cpp_name, want, fargs, fail_with_exception);
148 const typet &function_type);
152 const symbolt &template_symbol,
190 const symbolt &template_symbol,
218 const std::string &suffix);
252 const irept &initializers);
260 irept &initializers);
295 std::set<irep_idt> &bases,
296 std::set<irep_idt> &vbases,
300 const typet &t2)
const;
349 bool tag_only_declaration);
386 const symbolt &compound_symbol,
389 const typet &method_qualifier,
393 const symbolt &compound_symbol,
395 const typet &method_qualifier);
507 const exprt &expr,
const typet &type,
exprt &new_expr,
unsigned &rank);
510 const exprt &expr,
const typet &type,
exprt &new_expr,
unsigned &rank);
517 unsigned &rank)
const;
526 const exprt &expr,
const typet &type,
exprt &new_expr,
unsigned &rank);
529 const exprt &expr,
const typet &type,
unsigned &rank);
539 std::set<irep_idt> &set_bases)
const;
542 std::list<irep_idt> &vbases)
const;
566 bool check_constantness=
true);
572 bool check_constantness=
true);
ANSI-C Language Type Checking.
A base class for relations, i.e., binary predicates whose two operands have the same type.
A codet representing sequential composition of program statements.
codet representation of an if-then-else statement.
codet representing a while statement.
Data structure for representing an arbitrary statement in a program.
exprt resolve(const cpp_namet &cpp_name, const wantt want, const cpp_typecheck_fargst &fargs, bool fail_with_exception=true)
instantiation_stackt & instantiation_stack
instantiation_levelt(instantiation_stackt &_instantiation_stack)
cpp_template_args_tct full_template_args
source_locationt source_location
bool find_parent(const symbolt &symb, const irep_idt &base_name, irep_idt &identifier)
void default_assignop(const symbolt &symbol, cpp_declarationt &cpctor)
Generate declaration of the implicit default assignment operator.
bool reference_compatible(const exprt &expr, const reference_typet &type, unsigned &rank) const
Reference-compatible.
void typecheck_expr_typecast(exprt &) override
void typecheck_compound_body(symbolt &symbol)
void do_virtual_table(const symbolt &symbol)
void static_and_dynamic_initialization()
Initialization of static objects:
std::string template_suffix(const cpp_template_args_tct &template_args)
std::set< irep_idt > methods_seen
void typecheck_side_effect_assignment(side_effect_exprt &) override
bool implicit_conversion_sequence(const exprt &expr, const typet &type, exprt &new_expr, unsigned &rank)
implicit conversion sequence
bool standard_conversion_floating_point_conversion(const exprt &expr, const typet &type, exprt &new_expr) const
Floating-point conversion.
void put_compound_into_scope(const struct_union_typet::componentt &component)
std::string class_template_identifier(const irep_idt &base_name, const template_typet &template_type, const cpp_template_args_non_tct &partial_specialization_args)
void typecheck_type(typet &) override
void convert_anon_struct_union_member(const cpp_declarationt &declaration, const irep_idt &access, struct_typet::componentst &components)
void typecheck_switch(codet &) override
void explicit_typecast_ambiguity(exprt &)
void typecheck_compound_body(struct_union_typet &) override
instantiation_stackt instantiation_stack
void full_member_initialization(const struct_union_typet &struct_union_type, irept &initializers)
Build the full initialization list of the constructor.
bool contains_cpp_name(const exprt &)
void typecheck_decl(codet &) override
template_mapt template_map
bool reinterpret_typecast(const exprt &expr, const typet &type, exprt &new_expr, bool check_constantness=true)
std::string function_template_identifier(const irep_idt &base_name, const template_typet &template_type, const typet &function_type)
void do_not_typechecked()
void typecheck_enum_type(typet &type)
void convert_pmop(exprt &expr)
void typecheck_expr_sizeof(exprt &) override
void add_base_components(const struct_typet &from, const irep_idt &access, struct_typet &to, std::set< irep_idt > &bases, std::set< irep_idt > &vbases, bool is_virtual)
static bool has_const(const typet &type)
dynamic_initializationst dynamic_initializations
bool standard_conversion_boolean(const exprt &expr, exprt &new_expr) const
Boolean conversion.
void typecheck_code(codet &) override
std::list< method_bodyt > method_bodiest
void convert_template_declaration(cpp_declarationt &declaration)
bool standard_conversion_pointer(const exprt &expr, const typet &type, exprt &new_expr)
Pointer conversion.
void convert_function(symbolt &symbol)
void typecheck_expr_explicit_typecast(exprt &)
void typecheck_compound_declarator(const symbolt &symbol, const cpp_declarationt &declaration, cpp_declaratort &declarator, struct_typet::componentst &components, const irep_idt &access, bool is_static, bool is_typedef, bool is_mutable)
void implicit_typecast(exprt &expr, const typet &type) override
void typecheck_cast_expr(exprt &)
void salvage_default_arguments(const template_typet &old_type, template_typet &new_type)
bool reference_related(const exprt &expr, const reference_typet &type) const
Reference-related.
void default_dtor(const symbolt &symb, cpp_declarationt &dtor)
Note:
bool standard_conversion_integral_conversion(const exprt &expr, const typet &type, exprt &new_expr) const
Integral conversion.
bool standard_conversion_sequence(const exprt &expr, const typet &type, exprt &new_expr, unsigned &rank)
Standard Conversion Sequence.
void typecheck_expr_dereference(exprt &) override
void convert_non_template_declaration(cpp_declarationt &declaration)
irep_idt current_linkage_spec
bool standard_conversion_qualification(const exprt &expr, const typet &, exprt &new_expr) const
Qualification conversion.
void typecheck_function_template(cpp_declarationt &declaration)
typecheck function templates
unsigned template_counter
void typecheck_member_initializer(codet &)
bool check_component_access(const struct_union_typet::componentt &component, const struct_union_typet &struct_union_type)
void typecheck_side_effect_function_call(side_effect_expr_function_callt &) override
std::list< instantiationt > instantiation_stackt
void typecheck_member_function(const symbolt &compound_symbol, struct_typet::componentt &component, irept &initializers, const typet &method_qualifier, exprt &value)
bool cpp_is_pod(const typet &type) const
void convert_initializer(symbolt &symbol)
Initialize an object with a value.
void check_fixed_size_array(typet &type)
check that an array has fixed size
void default_cpctor(const symbolt &, cpp_declarationt &cpctor) const
Generate code for implicit default copy constructor.
bool standard_conversion_floating_point_promotion(const exprt &expr, exprt &new_expr) const
Floating-point-promotion conversion.
bool find_assignop(const symbolt &symbol) const
bool get_component(const source_locationt &source_location, const exprt &object, const irep_idt &component_name, exprt &member)
bool standard_conversion_floating_integral_conversion(const exprt &expr, const typet &type, exprt &new_expr) const
Floating-integral conversion.
bool const_typecast(const exprt &expr, const typet &type, exprt &new_expr)
void new_temporary(const source_locationt &source_location, const typet &, const exprt::operandst &ops, exprt &temporary)
void typecheck_compound_type(struct_union_typet &) override
void add_anonymous_members_to_scope(const symbolt &struct_union_symbol)
std::optional< codet > cpp_constructor(const source_locationt &source_location, const exprt &object, const exprt::operandst &operands)
void typecheck_expr_trinary(if_exprt &) override
void typecheck_class_template_member(cpp_declarationt &declaration)
typecheck class template members; these can be methods or static members
codet dtor(const symbolt &symb, const symbol_exprt &this_expr)
produces destructor code for a class object
void typecheck_try_catch(codet &)
void get_virtual_bases(const struct_typet &type, std::list< irep_idt > &vbases) const
void typecheck_expr_rel(binary_relation_exprt &) override
void typecheck_expr_reference_to(exprt &)
void show_instantiation_stack(std::ostream &)
bool standard_conversion_function_to_pointer(const exprt &expr, exprt &new_expr) const
Function-to-pointer conversion.
cpp_template_args_tct typecheck_template_args(const source_locationt &source_location, const symbolt &template_symbol, const cpp_template_args_non_tct &template_args)
void convert(cpp_linkage_spect &)
bool standard_conversion_array_to_pointer(const exprt &expr, exprt &new_expr) const
Array-to-pointer conversion.
std::unordered_set< irep_idt > deferred_typechecking
bool dynamic_typecast(const exprt &expr, const typet &type, exprt &new_expr)
void add_method_body(symbolt *_method_symbol)
void check_member_initializers(const struct_typet::basest &bases, const struct_typet::componentst &components, const irept &initializers)
Check a constructor initialization-list.
void typecheck_expr_binary_arithmetic(exprt &) override
void typecheck_expr_delete(exprt &)
method_bodiest method_bodies
void default_assignop_value(const symbolt &symbol, cpp_declaratort &declarator)
Generate code for the implicit default assignment operator.
bool support_float16_type
cpp_scopet & sub_scope_for_instantiation(cpp_scopet &template_scope, const std::string &suffix)
Set up a scope as subscope of the template scope.
cpp_typecheckt(cpp_parse_treet &_cpp_parse_tree, symbol_table_baset &_symbol_table, const std::string &_module, message_handlert &message_handler)
void typecheck_ifthenelse(code_ifthenelset &) override
cpp_scopet & tag_scope(const irep_idt &_base_name, bool has_body, bool tag_only_declaration)
void typecheck_compound_bases(struct_typet &type)
void typecheck_expr_main(exprt &) override
Called after the operands are done.
void elaborate_class_template(const typet &type)
elaborate class template instances
static bool has_auto(const typet &type)
bool builtin_factory(const irep_idt &) override
static bool has_volatile(const typet &type)
void typecheck_method_bodies()
bool operator_is_overloaded(exprt &)
bool user_defined_conversion_sequence(const exprt &expr, const typet &type, exprt &new_expr, unsigned &rank)
User-defined conversion sequence.
~cpp_typecheckt() override
bool standard_conversion_lvalue_to_rvalue(const exprt &expr, exprt &new_expr) const
Lvalue-to-rvalue conversion.
irep_idt function_identifier(const typet &type)
for function overloading
bool cast_away_constness(const typet &t1, const typet &t2) const
void typecheck() override
typechecking main method
void typecheck_expr_new(exprt &)
codet convert_anonymous_union(cpp_declarationt &declaration)
void add_implicit_dereference(exprt &)
void typecheck_expr_cpp_name(exprt &, const cpp_typecheck_fargst &)
void typecheck_expr(exprt &) override
void typecheck_friend_declaration(symbolt &symbol, cpp_declarationt &cpp_declaration)
void add_this_to_method_type(const symbolt &compound_symbol, code_typet &method_type, const typet &method_qualifier)
void typecheck_expr_side_effect(side_effect_exprt &) override
void typecheck_expr_comma(exprt &) override
bool static_typecast(const exprt &expr, const typet &type, exprt &new_expr, bool check_constantness=true)
bool subtype_typecast(const struct_typet &from, const struct_typet &to) const
void make_ptr_typecast(exprt &expr, const pointer_typet &dest_type)
void convert_parameter(const irep_idt ¤t_mode, code_typet::parametert ¶meter)
std::optional< codet > cpp_destructor(const source_locationt &source_location, const exprt &object)
void typecheck_enum_body(symbolt &symbol)
void typecheck_expr_explicit_constructor_call(exprt &)
bool standard_conversion_integral_promotion(const exprt &expr, exprt &new_expr) const
Integral-promotion conversion.
bool find_cpctor(const symbolt &symbol) const
void typecheck_function_expr(exprt &, const cpp_typecheck_fargst &)
cpp_scopet & typecheck_template_parameters(template_typet &type)
void move_member_initializers(irept &initializers, const code_typet &type, exprt &value)
void convert(cpp_declaratort &)
void typecheck_method_application(side_effect_expr_function_callt &)
std::string to_string(const typet &) override
bool disable_access_control
void elaborate_class_template(const source_locationt &source_location, const struct_tag_typet &type)
void typecheck_expr_this(exprt &)
void typecheck_expr_throw(exprt &)
bool overloadable(const exprt &)
void typecheck_block(code_blockt &) override
std::list< irep_idt > dynamic_initializationst
void convert_parameters(const irep_idt ¤t_mode, code_typet &function_type)
void typecheck_while(code_whilet &) override
const struct_typet & this_struct_type()
void typecheck_expr_index(exprt &) override
void typecheck_side_effect_inc_dec(side_effect_exprt &)
void zero_initializer(const exprt &object, const typet &type, const source_locationt &source_location, exprt::operandst &ops)
bool standard_conversion_pointer_to_member(const exprt &expr, const typet &type, exprt &new_expr)
Pointer-to-member conversion.
void typecheck_class_template(cpp_declarationt &declaration)
cpp_parse_treet & cpp_parse_tree
void typecheck_function_call_arguments(side_effect_expr_function_callt &) override
const symbolt & instantiate_template(const source_locationt &source_location, const symbolt &symbol, const cpp_template_args_tct &specialization_template_args, const cpp_template_args_tct &full_template_args, const typet &specialization=uninitialized_typet{})
void typecheck_expr_ptrmember(exprt &) override
const symbolt & class_template_symbol(const source_locationt &source_location, const symbolt &template_symbol, const cpp_template_args_tct &specialization_template_args, const cpp_template_args_tct &full_template_args)
void default_ctor(const source_locationt &source_location, const irep_idt &base_name, cpp_declarationt &ctor) const
Generate code for implicit default constructors.
exprt resolve(const cpp_namet &cpp_name, const cpp_typecheck_resolvet::wantt want, const cpp_typecheck_fargst &fargs, bool fail_with_exception=true)
void get_bases(const struct_typet &type, std::set< irep_idt > &set_bases) const
void convert_template_function_or_member_specialization(cpp_declarationt &declaration)
void convert_class_template_specialization(cpp_declarationt &declaration)
void typecheck_expr_address_of(exprt &) override
void reference_initializer(exprt &expr, const reference_typet &type)
A reference to type "cv1 T1" is initialized by an expression of type "cv2 T2" as follows:
bool find_dtor(const symbolt &symbol) const
bool reference_binding(exprt expr, const reference_typet &type, exprt &new_expr, unsigned &rank)
Reference binding.
void typecheck_expr_function_identifier(exprt &) override
void typecheck_expr_member(exprt &) override
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
std::vector< exprt > operandst
The trinary if-then-else operator.
There are a large number of kinds of tree structured or tree-like data in CPROVER.
message_handlert * message_handler
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
A side_effect_exprt representation of a function call side effect.
An expression containing a side effect.
A struct tag type, i.e., struct_typet with an identifier.
Structure type, corresponds to C style structs.
std::vector< baset > basest
Base type for structs and unions.
std::vector< componentt > componentst
Expression to hold a symbol (variable)
The symbol table base class interface.
The type of an expression, extends irept.
C++ Language Type Checking.
bool cpp_typecheck(cpp_parse_treet &cpp_parse_tree, symbol_table_baset &symbol_table, const std::string &module, message_handlert &message_handler)
C++ Language Type Checking.
#define UNREACHABLE
This should be used to mark dead code.
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
template_mapt template_map
instantiation_stackt instantiation_stack
method_bodyt(symbolt *_method_symbol, const template_mapt &_template_map, const instantiation_stackt &_instantiation_stack)
C++ Language Type Checking.