1#ifndef CLANG_C_FRONTEND_CLANG_C_CONVERT_H_
2#define CLANG_C_FRONTEND_CLANG_C_CONVERT_H_
4#define __STDC_LIMIT_MACROS
5#define __STDC_FORMAT_MACROS
12#include <unordered_map>
31class CompoundAssignOperator;
38class CharacterLiteral;
46class EnumConstantDecl;
50class TemplateParamObjectDecl;
62 std::unique_ptr<clang::ASTUnit> &_AST,
87 std::unique_ptr<clang::ASTUnit> &
AST;
123 clang::SourceManager *
sm;
146 virtual bool get_decl(
const clang::Decl &decl,
exprt &new_expr);
148 virtual bool get_var(
const clang::VarDecl &vd,
exprt &new_expr);
149 virtual const clang::Expr &elided_copy_source(
const clang::Expr &init);
150 bool has_dynamic_local_init(
const clang::VarDecl &vd)
const;
151 void add_init_guard(
const symbolt &var);
152 bool get_static_var_init(
153 const clang::VarDecl &vd,
159 std::string header_internal_suffix(
const clang::NamedDecl &nd);
162 std::unordered_map<std::string, std::vector<const clang::Decl *>>
165 virtual bool get_function(
const clang::FunctionDecl &fd,
exprt &new_expr);
167 bool get_function_signature(
const clang::FunctionDecl &fd,
code_typet &type);
169 virtual bool get_function_body(
170 const clang::FunctionDecl &fd,
191 const clang::FunctionDecl &fd,
207 const clang::ParmVarDecl &pd,
222 const clang::RecordDecl &recordd,
237 const clang::RecordDecl &recordd,
240 virtual bool get_type(
const clang::QualType &type,
typet &new_type);
242 virtual bool get_type(
const clang::Type &the_type,
typet &new_type);
249 const clang::FieldDecl &,
250 const typet &orig_type,
264 virtual bool get_expr(
const clang::Stmt &stmt,
exprt &new_expr);
267 const clang::InitListExpr &init,
268 std::vector<exprt> &flat);
282 const clang::BinaryOperator &binop,
290 const clang::CompoundAssignOperator &compop,
311 get_decl_name(
const clang::NamedDecl &vd, std::string &name, std::string &
id);
326 clang::PresumedLoc &PLoc,
327 std::string &function_name,
331 const clang::SourceLocation &loc,
332 clang::PresumedLoc &PLoc);
340 const clang::CharacterLiteral &char_literal,
348 const clang::IntegerLiteral &integer_literal,
352 const clang::FloatingLiteral &floating_literal,
384 const clang::FieldDecl *field,
436 const clang::TemplateParamObjectDecl &tpo,
437 const std::string &name,
438 const std::string &
id);
440 const clang::APValue &
value,
442 const clang::QualType *type =
nullptr);
460 const clang::Decl &d,
462 std::string &
id)
const;
std::string getFullyQualifiedName(const clang::QualType &, const clang::ASTContext &)
Definition clang_c_convert.cpp:5319
bool get_mangled_id(const clang::NamedDecl &nd, std::string &id)
The USR generator gives up on some C++20 declarations: a specialisation over a class-type template ar...
Definition clang_c_convert.cpp:5412
virtual bool get_struct_union_class_methods_decls(const clang::RecordDecl &recordd, typet &type)
Definition clang_c_convert.cpp:495
void get_default_symbol(symbolt &symbol, irep_idt module_name, typet type, irep_idt base_name, irep_idt unique_name, locationt location)
Definition clang_c_convert.cpp:5291
void convert_expression_to_code(exprt &expr)
Definition clang_c_convert.cpp:5875
const clang::Decl * get_top_FunctionDecl_from_Stmt(const clang::Stmt &stmt)
Definition clang_c_convert.cpp:5907
bool add_template_param_object(const clang::TemplateParamObjectDecl &tpo, const std::string &name, const std::string &id)
bool process_aligned_attribute(const clang::AlignedAttr &aattr, typet &t) const
Definition clang_c_convert.cpp:5967
void get_final_location_from_stmt(const clang::Stmt &stmt, locationt &location)
Definition clang_c_convert.cpp:5756
bool get_vla_size(const clang::Expr &size, exprt &new_expr)
Definition clang_c_convert.cpp:700
void set_location(clang::PresumedLoc &PLoc, std::string &function_name, locationt &location)
Definition clang_c_convert.cpp:5814
void get_presumed_location(const clang::SourceLocation &loc, clang::PresumedLoc &PLoc)
Definition clang_c_convert.cpp:5795
virtual bool perform_virtual_dispatch(const clang::MemberExpr &member)
Definition clang_c_convert.cpp:6020
std::string tag_prefix
Definition clang_c_convert.h:106
void get_ref_to_struct_type(typet &type)
Definition clang_c_convert.cpp:6043
bool get_base_flattened_inits(const clang::InitListExpr &init, std::vector< exprt > &flat)
Definition clang_c_convert.cpp:2235
unsigned last_loc_column
Definition clang_c_convert.h:100
bool is_member_decl_static(const clang::MemberExpr &member)
Definition clang_c_convert.cpp:6073
std::string get_filename_from_path(std::string path)
Definition clang_c_convert.cpp:5867
std::unordered_map< const clang::Expr *, exprt > vla_size_snapshots
A block-scope VLA's size, bound to a local just before its declarator (C11 6.7.6.2p5,...
Definition clang_c_convert.h:119
virtual bool is_aggregate_type(const clang::QualType &q_type)
Definition clang_c_convert.cpp:6068
bool get_array_filler(const clang::InitListExpr &init, exprt &filler)
Definition clang_c_convert.cpp:2199
void rewrite_builtin_ref(const clang::Decl &d, std::string &name, std::string &id) const
Rewrites references to builtin functions to their ESBMC counterparts.
Definition clang_c_convert.cpp:4258
bool get_builtin_type(const clang::BuiltinType &bt, typet &new_type)
Definition clang_c_convert.cpp:1697
bool process_record_layout_attributes(const clang::RecordDecl &rd, typet &t) const
Definition clang_c_convert.cpp:5922
unsigned int current_scope_var_num
Definition clang_c_convert.h:108
bool get_binary_operator_expr(const clang::BinaryOperator &binop, exprt &new_expr)
Definition clang_c_convert.cpp:4673
virtual bool get_function_params(const clang::FunctionDecl &fd, code_typet::argumentst ¶ms)
Parse function parameters This function simply contains a loop to populate the code argument list and...
Definition clang_c_convert.cpp:1060
void get_location_from_decl(const clang::Decl &decl, locationt &location)
Definition clang_c_convert.cpp:5773
static void gen_typecast_to_union(const namespacet &ns, exprt &dest, const typet &type)
Perform the typecast by creating a tmp variable on RHS.
Definition typecast.cpp:78
bool get_enum_value(const clang::EnumConstantDecl *e, exprt &new_expr)
Definition clang_c_convert.cpp:4138
clang_c_convertert(contextt &_context, std::unique_ptr< clang::ASTUnit > &_AST, irep_idt _mode)
Definition clang_c_convert.cpp:42
clang::ASTContext * ASTContext
Definition clang_c_convert.h:84
bool last_loc_valid
Definition clang_c_convert.h:103
virtual bool get_struct_union_class_fields(const clang::RecordDecl &recordd, struct_union_typet &type)
Definition clang_c_convert.cpp:470
bool get_compound_assign_expr(const clang::CompoundAssignOperator &compop, exprt &new_expr)
Definition clang_c_convert.cpp:4897
void get_vector_comparison(const clang::BinaryOperator &binop, irep_idt relation, exprt lhs, exprt rhs, const typet &type, exprt &new_expr)
Definition clang_c_convert.cpp:4831
bool report_unsupported_init_list(const clang::InitListExpr &init_stmt)
Report an initializer list none of get_expr's arms models, with its type and source location....
Definition clang_c_convert.cpp:2313
virtual bool get_type(const clang::QualType &type, typet &new_type)
Definition clang_c_convert.cpp:1158
virtual bool get_unary_operator_expr(const clang::UnaryOperator &uniop, exprt &new_expr)
Definition clang_c_convert.cpp:4587
bool get_bitfield_type(const clang::FieldDecl &, const typet &orig_type, typet &new_type)
Definition clang_c_convert.cpp:2154
namespacet ns
Definition clang_c_convert.h:86
std::unique_ptr< clang::ASTUnit > & AST
Definition clang_c_convert.h:87
symbol_generator anon_symbol
Definition clang_c_convert.h:89
bool is_field_global_storage(const clang::FieldDecl *field)
Definition clang_c_convert.cpp:6012
virtual bool get_expr(const clang::Stmt &stmt, exprt &new_expr)
Definition clang_c_convert.cpp:2332
std::string last_loc_filename
Definition clang_c_convert.h:101
bool convert_integer_literal(const clang::IntegerLiteral &integer_literal, exprt &dest)
Definition clang_c_convert_literals.cpp:64
bool snapshot_vla_sizes(const clang::Decl &decl, codet &dest)
Definition clang_c_convert.cpp:644
std::vector< const clang::LabelDecl * > address_taken_labels
Address-taken labels of the function being converted, in the order the addresses appear.
Definition clang_c_convert.h:134
virtual bool get_member_expr(const clang::MemberExpr &memb, exprt &new_expr)
Definition clang_c_convert.cpp:5251
virtual void annotate_exception_specification(const clang::FunctionDecl &, typet &)
Since this class is inherited by clang-cpp-frontend, some get_* functions are made `virtual' to deal ...
Definition clang_c_convert.h:181
virtual bool convert_top_level_decl()
Definition clang_c_convert.cpp:86
unsigned last_loc_line
Definition clang_c_convert.h:99
bool check_alignment_attributes(const clang::FieldDecl *field, struct_typet::componentt &comp)
Definition clang_c_convert.cpp:5990
irep_idt mode
Definition clang_c_convert.h:88
code_blockt * current_block
During get_expr(), which also transforms blocks/scopes, this represents the latest opened blocks from...
Definition clang_c_convert.h:114
bool convert_string_literal(const clang::StringLiteral &string_literal, exprt &dest)
Definition clang_c_convert_literals.cpp:32
std::string last_loc_function
Definition clang_c_convert.h:102
bool get_atomic_expr(const clang::AtomicExpr &atm, exprt &new_expr)
Definition clang_c_convert.cpp:5026
virtual bool is_fd_virtual_or_overriding(const clang::FunctionDecl &fd)
Definition clang_c_convert.cpp:6026
bool get_APValue_expr(const clang::APValue &value, exprt &new_expr, const clang::QualType *type=nullptr)
Definition clang_c_convert.cpp:6090
bool is_unlowered_math_builtin(const std::string &name) const
__builtin_copysign and the other __builtin_ spellings of a <math.h> function have no body; the plain ...
Definition clang_c_convert.cpp:4244
static std::string get_decl_name(const clang::NamedDecl &nd)
Definition clang_c_convert.cpp:5307
virtual bool get_vft_binding_expr(const clang::MemberExpr &member, exprt &new_expr)
Definition clang_c_convert.cpp:6033
bool get_cast_expr(const clang::CastExpr &cast, exprt &new_expr)
Definition clang_c_convert.cpp:4292
bool get_function_param(const clang::ParmVarDecl &pd, exprt ¶m)
Parse each individual parameter of the function.
Definition clang_c_convert.cpp:1079
const clang::FunctionDecl * current_functionDecl
Definition clang_c_convert.h:125
clang::SourceManager * sm
Definition clang_c_convert.h:123
bool convert_builtin_types()
Definition clang_c_convert.cpp:67
bool wrap_bitfield_type_if_needed(const clang::FieldDecl &fd, typet &t)
Definition clang_c_convert.cpp:2132
contextt & context
Definition clang_c_convert.h:85
bool convert_float_literal(const clang::FloatingLiteral &floating_literal, exprt &dest)
Definition clang_c_convert_literals.cpp:150
virtual bool get_struct_union_class(const clang::RecordDecl &recordd)
Definition clang_c_convert.cpp:331
bool convert_character_literal(const clang::CharacterLiteral &char_literal, exprt &dest)
Definition clang_c_convert_literals.cpp:16
virtual bool get_decl_ref(const clang::Decl &decl, exprt &new_expr)
Definition clang_c_convert.cpp:4180
std::string get_modulename_from_path(std::string path)
Definition clang_c_convert.cpp:5857
locationt last_loc
Definition clang_c_convert.h:98
virtual ~clang_c_convertert()=default
void collect_address_taken_labels(const clang::Stmt &body)
Definition clang_c_convert.cpp:1027
virtual void name_param_and_continue(const clang::ParmVarDecl &pd, std::string &id, std::string &name, exprt ¶m)
Definition clang_c_convert.cpp:1144
void size_flexible_array_member(const clang::ValueDecl &vd, typet &t)
Definition clang_c_convert.cpp:2146
const clang::Decl * get_DeclContext_from_Stmt(const clang::Stmt &stmt)
Definition clang_c_convert.cpp:5888
bool convert()
Definition clang_c_convert.cpp:59
void get_start_location_from_stmt(const clang::Stmt &stmt, locationt &location)
Definition clang_c_convert.cpp:5739
Definition std_types.h:280
std::vector< argumentt > argumentst
Definition std_types.h:283
Definition namespace.h:10
Definition std_types.h:87
Definition std_types.h:78
Definition symbol_generator.h:7
Definition build_ast.h:13
static std::optional< std::string > string_literal(const nlohmann::json &node)
Definition expr.cpp:7235