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