1#ifndef CLANG_CPP_FRONTEND_CLANG_CPP_CONVERT_H_
2#define CLANG_CPP_FRONTEND_CLANG_CPP_CONVERT_H_
4#define __STDC_LIMIT_MACROS
5#define __STDC_FORMAT_MACROS
15 std::unique_ptr<clang::ASTUnit> &_AST,
22 typedef std::unordered_map<std::size_t, std::pair<std::string, typet>>
26 bool get_decl(
const clang::Decl &decl,
exprt &new_expr)
override;
29 const clang::NamedDecl &nd,
31 std::string &
id)
override;
40 bool get_type(
const clang::QualType &type,
typet &new_type)
override;
42 bool get_type(
const clang::Type &the_type,
typet &new_type)
override;
47 const clang::CXXMethodDecl &md,
51 const clang::FunctionDecl &fd,
52 typet &type)
override;
58 const clang::CXXConstructExpr &constructor_call,
61#if CLANG_VERSION_MAJOR <= 15
62# define CAPTURE_VARIABLE_TYPE clang::VarDecl
64# define CAPTURE_VARIABLE_TYPE clang::ValueDecl
75 typedef llvm::DenseMap<const CAPTURE_VARIABLE_TYPE *, clang::FieldDecl *>
78 unordered_map<std::size_t, std::pair<field_mapt, clang::FieldDecl *>>
88 const auto *methodDecl =
91 const auto *parent = methodDecl->getParent();
92 if (parent && parent->isLambda())
99 const clang::FunctionDecl &fd,
105 const clang::Expr &init,
106 const typet &member_type,
112 const clang::CXXMethodDecl &invoker,
120 const clang::FunctionDecl &fd,
124 const clang::ParmVarDecl &pd,
127 exprt ¶m)
override;
139 const clang::CXXMethodDecl &fd,
144 bool get_var(
const clang::VarDecl &vd,
exprt &new_expr)
override;
148 const clang::RecordDecl &rd,
152 const clang::RecordDecl &rd,
153 typet &type)
override;
161 template <
typename TemplateDecl>
163 const TemplateDecl &D,
164 bool DumpExplicitInst,
167 template <
typename SpecializationDecl>
169 const SpecializationDecl *D,
170 bool DumpExplicitInst,
173 bool get_expr(
const clang::Stmt &stmt,
exprt &new_expr)
override;
203 const this_mapt::mapped_type &
207 const clang::FieldDecl &field,
212 const clang::CXXRecordDecl &
base,
213 const clang::CXXMethodDecl &md);
220 const clang::CXXMethodDecl &md,
221 std::vector<subobject_destructort> &out);
241 const clang::CXXConstructorDecl &cd,
242 std::size_t body_start,
252 const clang::CXXConstructorDecl &cd,
253 const std::vector<std::size_t> &starts,
260 const clang::CXXConstructorDecl &cd,
262 std::vector<std::size_t> starts,
271 const clang::CXXRecordDecl &
base,
274 const typet &this_ptr_type);
284 const clang::FieldDecl &field,
294 const clang::FieldDecl &field,
338 const clang::CXXMethodDecl &cxxmdd,
339 typet &ctor_return_type);
350 const clang::CXXMethodDecl &cxxmdd,
373 const exprt &callee_decl,
387 const clang::CXXConstructorDecl &cxxcd,
395 const clang::Stmt *parentStmt,
396 const clang::CXXConstructExpr &call);
408 std::vector<std::pair<std::string, const clang::CXXRecordDecl *>>;
461 bool has_virtual_bases,
462 const clang::CXXRecordDecl &cxxrd);
481 const std::string &type_name,
482 const clang::Stmt &stmt,
508 const clang::CXXRecordDecl &cxxrd,
519 const clang::CXXMethodDecl &md,
575 const clang::CXXMethodDecl &md,
583 typet &thunk_symbol_type,
584 const std::string &base_class_id);
612 const exprt &late_cast_this);
624 const exprt &late_cast_this);
633 const symbolt &thunk_func_symb,
655 const clang::CXXRecordDecl &cxxrd,
695 const clang::CXXRecordDecl &cxxrd,
724 std::map<irep_idt, std::unordered_set<const clang::CXXRecordDecl *>>
765 const clang::CXXMethodDecl &md,
767 const exprt &base_deref);
777 const clang::CXXMethodDecl &md,
779 const exprt &vtable_ptr_deref);
784 const clang::CXXMethodDecl &md,
787 const clang::UnaryOperator &uniop,
788 exprt &new_expr)
override;
817 const clang::ConditionalOperator &ternary,
824 const clang::QualType &type,
825 const clang::ParmVarDecl ¶m,
833 const clang::CXXNewExpr &ne,
static const twodig_t base
Definition bigint.cpp:28
clang_c_convertert(contextt &_context, std::unique_ptr< clang::ASTUnit > &_AST, irep_idt _mode)
Definition clang_c_convert.cpp:42
const clang::FunctionDecl * current_functionDecl
Definition clang_c_convert.h:125
bool build_dynamic_cast(const clang::CXXDynamicCastExpr &cast, exprt &new_expr)
Definition clang_cpp_convert_vft.cpp:959
bool get_new_storage(const clang::CXXNewExpr &ne, exprt &new_expr)
Definition clang_cpp_convert.cpp:4191
void gen_typecast_base_ctor_call(const exprt &callee_decl, side_effect_expr_function_callt &call, exprt &initializer)
Definition clang_cpp_convert.cpp:3754
bool need_new_object(const clang::Stmt *parentStmt, const clang::CXXConstructExpr &call)
Definition clang_cpp_convert.cpp:3821
bool get_align_val(const clang::QualType &type, const clang::ParmVarDecl ¶m, exprt &align)
Definition clang_cpp_convert.cpp:4269
bool get_dealloc_function(const clang::CXXDeleteExpr &de, exprt &new_expr)
Definition clang_cpp_convert.cpp:4239
void add_thunk_method(const clang::CXXMethodDecl &md, const struct_typet::componentt &component, struct_typet &type)
Definition clang_cpp_convert_vft.cpp:349
bool build_lambda_static_invoker(const clang::CXXMethodDecl &invoker, exprt &new_expr)
Body for a lambda's static invoker: forward to the closure's operator().
Definition clang_cpp_convert.cpp:2558
bool get_decl_ref(const clang::Decl &decl, exprt &new_expr) override
Get reference to a declared variable or function, e.g:
Definition clang_cpp_convert.cpp:3434
bool get_template_decl_specialization(const SpecializationDecl *D, bool DumpExplicitInst, exprt &new_expr)
Definition clang_cpp_convert.cpp:3386
void get_base_components_methods(base_map &map, struct_union_typet &type, bool has_virtual_bases, const clang::CXXRecordDecl &cxxrd)
Definition clang_cpp_convert.cpp:3899
void build_member_from_component(const clang::FunctionDecl &fd, exprt &component)
Definition clang_cpp_convert.cpp:2080
std::string vtable_ptr_suffix
Definition clang_cpp_convert.h:469
bool get_function_params(const clang::FunctionDecl &fd, code_typet::argumentst ¶ms) override
Get function params for C++ contains conversion routines specific to C++ class member functions.
Definition clang_cpp_convert.cpp:3263
bool get_access_from_decl(const clang::Decl &decl, std::string &access)
Definition clang_cpp_convert.cpp:3594
exprt typeid_object(const exprt &value, const std::string &type_name, const clang::Stmt &stmt, bool dynamic)
The object a typeid expression refers to, which has static storage duration ([expr....
Definition clang_cpp_convert.cpp:827
bool get_struct_union_class_fields(const clang::RecordDecl &rd, struct_union_typet &type) override
Definition clang_cpp_convert.cpp:548
bool get_function_body(const clang::FunctionDecl &fd, exprt &new_expr, const code_typet &ftype) override
Definition clang_cpp_convert.cpp:2709
symbolt * check_vtable_type_symbol_existence(const struct_typet &type)
Definition clang_cpp_convert_vft.cpp:166
void add_vtable_type_entry(struct_typet &type, struct_typet::componentt &comp, symbolt *vtable_type_symbol)
Definition clang_cpp_convert_vft.cpp:300
bool get_placement_new(const clang::CXXNewExpr &ne, const typet &t, const locationt &location, exprt &new_expr)
Definition clang_cpp_convert.cpp:4284
bool annotate_class_field(const clang::FieldDecl &field, const struct_union_typet &type, struct_typet::componentt &comp)
Definition clang_cpp_convert.cpp:3559
exprt base_dtor_this(const clang::CXXRecordDecl &base, const exprt &deref, const irep_idt &this_id, const typet &this_ptr_type)
Definition clang_cpp_convert.cpp:2114
std::string constref_suffix
Definition clang_cpp_convert.h:129
void get_overriden_methods(const clang::CXXMethodDecl &md, overriden_map &map)
Definition clang_cpp_convert_vft.cpp:860
void add_thunk_method_arguments(symbolt &thunk_func_symb)
Definition clang_cpp_convert_vft.cpp:485
bool get_vft_binding_expr(const clang::MemberExpr &member, exprt &new_expr) override
Definition clang_cpp_convert_bind.cpp:85
void add_thunk_method_body(symbolt &thunk_func_symb, const struct_typet::componentt &component)
Definition clang_cpp_convert_vft.cpp:552
bool get_conditional_class_prvalue(const clang::ConditionalOperator &ternary, exprt &new_expr, bool &elided)
Definition clang_cpp_convert.cpp:4134
std::map< std::string, const clang::CXXMethodDecl & > overriden_map
Definition clang_cpp_convert.h:490
cap_mapt cap_map
Definition clang_cpp_convert.h:80
std::map< irep_idt, function_switch > switch_table
Definition clang_cpp_convert.h:489
void name_param_and_continue(const clang::ParmVarDecl &pd, std::string &id, std::string &name, exprt ¶m) override
Definition clang_cpp_convert.cpp:3326
void make_temporary(exprt &expr)
Definition clang_cpp_convert.cpp:4381
bool annotate_virtual_overriding_methods(const clang::CXXMethodDecl &md, struct_typet::componentt &comp)
Definition clang_cpp_convert_vft.cpp:146
bool get_method_declaration(const clang::CXXMethodDecl &md, const symbolt *&symbol)
Definition clang_cpp_convert.cpp:472
this_mapt this_map
Definition clang_cpp_convert.h:24
void annotate_exception_specification(const clang::FunctionDecl &fd, typet &type) override
Since this class is inherited by clang-cpp-frontend, some get_* functions are made `virtual' to deal ...
Definition clang_cpp_convert.cpp:3129
std::string rtti_type_name(const clang::QualType &qtype)
Definition clang_cpp_convert_vft.cpp:178
std::string thunk_prefix
Definition clang_cpp_convert.h:486
code_function_callt base_destructor(const symbolt &sym, const clang::CXXRecordDecl &base, const clang::CXXMethodDecl &md)
Definition clang_cpp_convert.cpp:2221
void annotate_ctor_dtor_rtn_type(const clang::CXXMethodDecl &cxxmdd, typet &rtn_type)
Definition clang_cpp_convert.cpp:4042
bool get_base_map(const clang::CXXRecordDecl &cxxrd, base_map &map)
Definition clang_cpp_convert.cpp:3860
const clang::Expr & elided_copy_source(const clang::Expr &init) override
Definition clang_cpp_convert.cpp:2676
virtual ~clang_cpp_convertert()=default
bool get_method(const clang::CXXMethodDecl &md, exprt &new_expr)
Definition clang_cpp_convert.cpp:508
bool is_lambda() const
Definition clang_cpp_convert.h:82
bool get_decl(const clang::Decl &decl, exprt &new_expr) override
Definition clang_cpp_convert.cpp:48
bool get_struct_union_class(const clang::RecordDecl &rd) override
Definition clang_cpp_convert.cpp:539
bool user_code_uses_exceptions()
Definition clang_cpp_convert.cpp:2336
bool get_vft_binding_expr_base(const clang::MemberExpr &member, exprt &new_expr)
Definition clang_cpp_convert_bind.cpp:114
symbolt * get_fd_symbol(const clang::FunctionDecl &fd)
Definition clang_cpp_convert.cpp:3852
clang_cpp_convertert(contextt &_context, std::unique_ptr< clang::ASTUnit > &_AST, irep_idt _mode)
Definition clang_cpp_convert.cpp:40
bool get_constructor_call(const clang::CXXConstructExpr &constructor_call, exprt &new_expr)
Get reference for constructor callsite.
Definition clang_cpp_convert.cpp:1979
bool member_destructor(const clang::FieldDecl &field, const exprt &deref, code_blockt &calls)
Definition clang_cpp_convert.cpp:2170
bool get_struct_class_virtual_methods(const clang::CXXRecordDecl &cxxrd, struct_typet &type)
Definition clang_cpp_convert_vft.cpp:42
static irep_idt rtti_name_component_id(const irep_idt &vtable_type_id)
Definition clang_cpp_convert_vft.cpp:210
bool insert_constructor_initializers(const clang::CXXConstructorDecl &cd, exprt::operandst &initializers, std::vector< std::size_t > starts, const symbolt *array_init_sym, code_blockt &body)
Definition clang_cpp_convert.cpp:2503
bool get_member_expr(const clang::MemberExpr &memb, exprt &new_expr) override
Definition clang_cpp_convert.cpp:3724
void add_thunk_method_body_no_return(symbolt &thunk_func_symb, const struct_typet::componentt &component, const exprt &late_cast_this)
Definition clang_cpp_convert_vft.cpp:649
bool get_new_initializer(const clang::CXXNewExpr &ne, exprt &new_expr)
Attach a new-expression's initializer, and for an array its braced list's filler: a run-time element ...
Definition clang_cpp_convert.cpp:788
void get_vft_binding_expr_vtable_ptr(const clang::CXXMethodDecl &md, exprt &new_expr, const exprt &base_deref)
Definition clang_cpp_convert_bind.cpp:134
bool has_vptr_component
Definition clang_cpp_convert.h:485
std::unordered_map< std::size_t, std::pair< std::string, typet > > this_mapt
Definition clang_cpp_convert.h:23
bool get_function_this_pointer_param(const clang::CXXMethodDecl &fd, code_typet::argumentst ¶ms)
Add implicit this' when parsing C++ class member functions, e.g: class t1 { int i; t1(){i = 1}...
Definition clang_cpp_convert.cpp:3171
void set_thunk_name(symbolt &thunk_func_symb, const std::string &base_class_id)
Definition clang_cpp_convert_vft.cpp:448
symbolt * add_vtable_type_symbol(const struct_typet::componentt &comp, struct_typet &type)
Definition clang_cpp_convert_vft.cpp:226
void build_vtable_map(const struct_typet &struct_type, switch_table &vtable_value_map)
Definition clang_cpp_convert_vft.cpp:716
bool get_cxx_constructor_is_complete_param(const clang::CXXConstructorDecl &cxxcd, code_typet::argumentt ¶m)
Definition clang_cpp_convert.cpp:3222
void add_vtable_variable_symbols(const clang::CXXRecordDecl &cxxrd, const struct_typet &struct_type, const switch_table &vtable_value_map)
Definition clang_cpp_convert_vft.cpp:760
bool destroy_object_on_body_unwind(const clang::CXXConstructorDecl &cd, std::size_t body_start, code_blockt &body)
Definition clang_cpp_convert.cpp:2396
void annotate_implicit_copy_move_ctor_union(const clang::CXXMethodDecl &cxxmdd, typet &ctor_return_type)
Definition clang_cpp_convert.cpp:4015
void pre_register_inherited_vtables(const clang::CXXRecordDecl &cxxrd)
Definition clang_cpp_convert_vft.cpp:889
bool is_fd_virtual_or_overriding(const clang::FunctionDecl &fd) override
Definition clang_cpp_convert_bind.cpp:76
bool build_destructor_chain(const clang::CXXDestructorDecl &dd, code_blockt &body)
Definition clang_cpp_convert.cpp:2530
std::map< irep_idt, exprt > function_switch
Definition clang_cpp_convert.h:488
bool annotate_class_method(const clang::CXXMethodDecl &cxxmdd, exprt &new_expr)
Definition clang_cpp_convert.cpp:3625
void get_decl_name(const clang::NamedDecl &nd, std::string &name, std::string &id) override
Definition clang_cpp_convert.cpp:222
bool is_md_virtual_or_overriding(const clang::CXXMethodDecl &cxxmd)
Definition clang_cpp_convert_bind.cpp:68
bool get_type(const clang::QualType &type, typet &new_type) override
Definition clang_cpp_convert.cpp:354
static struct_typet::componentt rtti_name_component(const irep_idt &vtable_type_id)
Definition clang_cpp_convert_vft.cpp:216
bool get_template_decl(const TemplateDecl &D, bool DumpExplicitInst, exprt &new_expr)
Definition clang_cpp_convert.cpp:3422
std::unordered_map< std::size_t, std::pair< field_mapt, clang::FieldDecl * > > cap_mapt
Definition clang_cpp_convert.h:79
bool is_defaulted_ctor(const clang::CXXMethodDecl &md)
Definition clang_cpp_convert.cpp:4033
bool get_struct_union_class_methods_decls(const clang::RecordDecl &rd, typet &type) override
Definition clang_cpp_convert.cpp:591
const symbolt * nontrivial_destructor(const clang::CXXRecordDecl *rec)
Definition clang_cpp_convert.cpp:2140
codet rethrowing_catch(const code_blockt &tried, code_blockt handler)
Definition clang_cpp_convert.cpp:2382
bool get_virtual_member_function_pointer(const clang::CXXMethodDecl &md, exprt &new_expr)
Definition clang_cpp_convert_bind.cpp:180
bool is_copy_or_move_ctor(const clang::DeclContext &dcxt)
Definition clang_cpp_convert.cpp:4025
bool is_duplicate_method(const struct_typet::componentt &method, const struct_union_typet &type)
Definition clang_cpp_convert.cpp:4001
std::string vcall_prefix
Definition clang_cpp_convert.h:487
bool is_CopyOrMoveOperator(const clang::CXXMethodDecl &md)
Definition clang_cpp_convert.cpp:4092
bool get_member_initializer(const clang::Expr &init, const typet &member_type, exprt &rhs)
Definition clang_cpp_convert.cpp:2689
void setup_vtable_struct_variables(const clang::CXXRecordDecl &cxxrd, const struct_typet &type)
Definition clang_cpp_convert_vft.cpp:693
void update_thunk_this_type(typet &thunk_symbol_type, const std::string &base_class_id)
Definition clang_cpp_convert_vft.cpp:464
bool get_ctor_dtor_ref(const clang::CXXMethodDecl &md, exprt &new_expr)
Definition clang_cpp_convert.cpp:3538
bool get_vft_binding_expr_function(const clang::CXXMethodDecl &md, exprt &new_expr, const exprt &vtable_ptr_deref)
Definition clang_cpp_convert_bind.cpp:154
bool perform_virtual_dispatch(const clang::MemberExpr &member) override
Definition clang_cpp_convert_bind.cpp:36
bool annotate_class_field_access(const clang::FieldDecl &field, struct_typet::componentt &comp)
Definition clang_cpp_convert.cpp:3581
void add_thunk_component_to_type(const symbolt &thunk_func_symb, struct_typet &type, const struct_typet::componentt &comp, const irep_idt &virtual_name)
Definition clang_cpp_convert_vft.cpp:680
bool get_unary_operator_expr(const clang::UnaryOperator &uniop, exprt &new_expr) override
Definition clang_cpp_convert_bind.cpp:252
void add_thunk_method_body_return(symbolt &thunk_func_symb, const struct_typet::componentt &component, const exprt &late_cast_this)
Definition clang_cpp_convert_vft.cpp:586
bool is_ConstructorOrDestructor(const clang::CXXMethodDecl &md)
Definition clang_cpp_convert.cpp:4097
llvm::DenseMap< const CAPTURE_VARIABLE_TYPE *, clang::FieldDecl * > field_mapt
Definition clang_cpp_convert.h:76
void add_vptr(struct_typet &type)
Definition clang_cpp_convert_vft.cpp:273
bool is_duplicate_component(const struct_typet::componentt &component, const struct_union_typet &type)
Definition clang_cpp_convert.cpp:3987
std::map< irep_idt, std::unordered_set< const clang::CXXRecordDecl * > > vtable_classes_per_vptr_
Definition clang_cpp_convert.h:725
std::optional< bool > uses_exceptions
Definition clang_cpp_convert.h:228
bool subobject_destructors(const clang::CXXMethodDecl &md, std::vector< subobject_destructort > &out)
Definition clang_cpp_convert.cpp:2235
bool get_expr(const clang::Stmt &stmt, exprt &new_expr) override
Definition clang_cpp_convert.cpp:936
bool get_var(const clang::VarDecl &vd, exprt &new_expr) override
Definition clang_cpp_convert.cpp:463
std::vector< std::pair< std::string, const clang::CXXRecordDecl * > > base_map
Definition clang_cpp_convert.h:407
const this_mapt::mapped_type & method_this(const clang::CXXMethodDecl &md) const
Definition clang_cpp_convert.cpp:2161
bool unwind_constructed_subobjects(const clang::CXXConstructorDecl &cd, const std::vector< std::size_t > &starts, code_blockt &body)
Definition clang_cpp_convert.cpp:2429
std::string vtable_type_prefix
Definition clang_cpp_convert.h:468
bool is_aggregate_type(const clang::QualType &q_type) override
Definition clang_cpp_convert.cpp:4053
A `switch' instruction */ class code_switcht : public codet { public: inline code_switcht() : codet("...
Definition std_code.h:574
Definition std_types.h:297
Definition std_types.h:280
std::vector< argumentt > argumentst
Definition std_types.h:283
std::vector< exprt > operandst
Definition expr.h:39
Definition std_code.h:905
Definition std_types.h:232
Definition std_types.h:87
Definition std_types.h:78
Definition clang_cpp_convert.h:197
std::size_t position
Definition clang_cpp_convert.h:198
code_blockt calls
Definition clang_cpp_convert.h:199