| CBMC
    | 
Class for generating initialisation code for compound structures. More...
#include <recursive_initialization.h>
 Collaboration diagram for recursive_initializationt:
 Collaboration diagram for recursive_initializationt:| Classes | |
| struct | constructor_keyt | 
| Public Types | |
| using | recursion_sett = std::set< irep_idt > | 
| using | equal_cluster_idt = std::size_t | 
| using | type_constructor_namest = std::map< constructor_keyt, irep_idt > | 
| Public Member Functions | |
| recursive_initializationt (recursive_initialization_configt initialization_config, goto_modelt &goto_model) | |
| void | initialize (const exprt &lhs, const exprt &depth, code_blockt &body) | 
| Generate initialisation code for lhs into body.  More... | |
| symbol_exprt | get_free_function () | 
| Get the freefunction as symbol expression, and inserts it into the goto-model if it doesn't exist already.  More... | |
| bool | needs_freeing (const exprt &expr) const | 
| void | free_if_possible (const exprt &expr, code_blockt &body) | 
| void | free_cluster_origins (code_blockt &body) | 
| Static Public Member Functions | |
| static bool | is_initialization_allowed (const symbolt &symbol) | 
| Private Member Functions | |
| symbol_exprt | get_malloc_function () | 
| Get the malloc function as symbol exprt, and inserts it into the goto-model if it doesn't exist already.  More... | |
| bool | should_be_treated_as_array (const irep_idt &pointer_name) const | 
| optionalt< equal_cluster_idt > | find_equal_cluster (const irep_idt &name) const | 
| bool | is_array_size_parameter (const irep_idt &cmdline_arg) const | 
| optionalt< irep_idt > | get_associated_size_variable (const irep_idt &array_name) const | 
| bool | should_be_treated_as_cstring (const irep_idt &pointer_name) const | 
| irep_idt | get_fresh_global_name (const std::string &symbol_name, const exprt &initial_value) const | 
| Construct a new global symbol of type intand set it's value toinitial_value.  More... | |
| symbol_exprt | get_fresh_global_symexpr (const std::string &symbol_name) const | 
| Construct a new global symbol of type intinitialised to 0.  More... | |
| symbol_exprt | get_fresh_local_symexpr (const std::string &symbol_name) const | 
| Construct a new local symbol of type intinitialised to 0.  More... | |
| symbol_exprt | get_fresh_local_typed_symexpr (const std::string &symbol_name, const typet &type) const | 
| Construct a new local symbol of type typeinitialised toinit_value.  More... | |
| const symbolt & | get_fresh_fun_symbol (const std::string &fun_name, const typet &fun_type) | 
| Construct a new function symbol of type fun_type.  More... | |
| symbolt & | get_fresh_param_symbol (const std::string ¶m_name, const typet ¶m_type) | 
| Construct a new parameter symbol of type param_type.  More... | |
| symbol_exprt | get_symbol_expr (const irep_idt &symbol_name) const | 
| Recover the symbol expression from symbol table.  More... | |
| std::string | type2id (const typet &type) const | 
| Simple pretty-printer for typet.  More... | |
| code_blockt | build_constructor_body (const exprt &depth_symbol, const symbol_exprt &result_symbol, const optionalt< exprt > &size_symbol, const optionalt< irep_idt > &lhs_name, const bool is_nullable) | 
| Case analysis for which constructor should be used.  More... | |
| irep_idt | build_constructor (const exprt &expr) | 
| Check if a constructor for the type of expralready exists and create it if not.  More... | |
| code_blockt | build_function_pointer_constructor (const symbol_exprt &result, bool is_nullable) | 
| Constructor for function pointers.  More... | |
| code_blockt | build_pointer_constructor (const exprt &depth, const symbol_exprt &result) | 
| Generic constructor for all pointers: only builds one pointee (not an array) but may recourse in case the pointee contains more pointers, e.g.  More... | |
| code_blockt | build_struct_constructor (const exprt &depth, const symbol_exprt &result) | 
| Constructor for structures: simply iterates over members and initialise each one.  More... | |
| code_blockt | build_nondet_constructor (const symbol_exprt &result) const | 
| Default constructor: assigns non-deterministic value of the right type.  More... | |
| code_blockt | build_array_constructor (const exprt &depth, const symbol_exprt &result) | 
| Constructor for arrays: simply iterates over elements and initialise each one.  More... | |
| code_blockt | build_dynamic_array_constructor (const exprt &depth, const symbol_exprt &result, const exprt &size, const optionalt< irep_idt > &lhs_name) | 
| Constructor for dynamic arrays: allocate memory for nelements (nis random but bounded) and initialise each one.  More... | |
| void | initialize_selected_member (const exprt &lhs, const exprt &depth, code_blockt &body, const std::vector< irep_idt > &selection_spec) | 
| Select the specified struct-member to be non-deterministically initialized.  More... | |
| Private Attributes | |
| const recursive_initialization_configt | initialization_config | 
| goto_modelt & | goto_model | 
| irep_idt | max_depth_var_name | 
| irep_idt | min_depth_var_name | 
| type_constructor_namest | type_constructor_names | 
| std::vector< optionalt< exprt > > | common_arguments_origins | 
Class for generating initialisation code for compound structures.
Definition at line 62 of file recursive_initialization.h.
| using recursive_initializationt::equal_cluster_idt = std::size_t | 
Definition at line 66 of file recursive_initialization.h.
| using recursive_initializationt::recursion_sett = std::set<irep_idt> | 
Definition at line 65 of file recursive_initialization.h.
| using recursive_initializationt::type_constructor_namest = std::map<constructor_keyt, irep_idt> | 
Definition at line 89 of file recursive_initialization.h.
| recursive_initializationt::recursive_initializationt | ( | recursive_initialization_configt | initialization_config, | 
| goto_modelt & | goto_model | ||
| ) | 
Definition at line 118 of file recursive_initialization.cpp.
| 
 | private | 
Constructor for arrays: simply iterates over elements and initialise each one.
| depth | symbol of the depth parameter | 
| result | symbol of the result parameter | 
Definition at line 745 of file recursive_initialization.cpp.
Check if a constructor for the type of expr already exists and create it if not. 
| expr | the expression to be constructed | 
Definition at line 291 of file recursive_initialization.cpp.
| 
 | private | 
Case analysis for which constructor should be used.
| depth_symbol | the symbol for depthparameter | 
| result_symbol | the symbol for resultparameter | 
| size_symbol | maybe the symbol for sizeparameter | 
| lhs_name | the name of the original symbol | 
| is_nullable | flag for setting a function pointer nullable | 
Definition at line 246 of file recursive_initialization.cpp.
| 
 | private | 
Constructor for dynamic arrays: allocate memory for n elements (n is random but bounded) and initialise each one. 
| depth | symbol of the depth parameter | 
| result | symbol of the result parameter | 
| size | symbol of the size parameter | 
| lhs_name | name of the original symbol | 
Definition at line 817 of file recursive_initialization.cpp.
| 
 | private | 
Constructor for function pointers.
| result | symbol of the result parameter | 
| is_nullable | if the function pointer can be null | 
Definition at line 984 of file recursive_initialization.cpp.
| 
 | private | 
Default constructor: assigns non-deterministic value of the right type.
| result | symbol of the result parameter | 
Definition at line 805 of file recursive_initialization.cpp.
| 
 | private | 
Generic constructor for all pointers: only builds one pointee (not an array) but may recourse in case the pointee contains more pointers, e.g.
a struct.
| depth | symbol of the depth parameter | 
| result | symbol of the result parameter | 
Definition at line 649 of file recursive_initialization.cpp.
| 
 | private | 
Constructor for structures: simply iterates over members and initialise each one.
| depth | symbol of the depth parameter | 
| result | symbol of the result parameter | 
Definition at line 767 of file recursive_initialization.cpp.
| 
 | private | 
Definition at line 400 of file recursive_initialization.cpp.
| void recursive_initializationt::free_cluster_origins | ( | code_blockt & | body | ) | 
Definition at line 976 of file recursive_initialization.cpp.
| void recursive_initializationt::free_if_possible | ( | const exprt & | expr, | 
| code_blockt & | body | ||
| ) | 
Definition at line 943 of file recursive_initialization.cpp.
| 
 | private | 
Definition at line 420 of file recursive_initialization.cpp.
| symbol_exprt recursive_initializationt::get_free_function | ( | ) | 
Get the free function as symbol expression, and inserts it into the goto-model if it doesn't exist already. 
free function Definition at line 632 of file recursive_initialization.cpp.
| 
 | private | 
Construct a new function symbol of type fun_type. 
| fun_name | the base name for the new symbol | 
| fun_type | type for the new symbol | 
Definition at line 558 of file recursive_initialization.cpp.
| 
 | private | 
Construct a new global symbol of type int and set it's value to initial_value. 
| symbol_name | the base name for the new symbol | 
| initial_value | the value the symbol should be initialised with | 
symbol_name) Definition at line 502 of file recursive_initialization.cpp.
| 
 | private | 
Construct a new global symbol of type int initialised to 0. 
| symbol_name | the base name for the new symbol | 
Definition at line 515 of file recursive_initialization.cpp.
| 
 | private | 
Construct a new local symbol of type int initialised to 0. 
| symbol_name | the base name for the new symbol | 
Definition at line 527 of file recursive_initialization.cpp.
| 
 | private | 
Construct a new local symbol of type type initialised to init_value. 
| symbol_name | the base name for the new symbol | 
| type | type for the new symbol | 
Definition at line 542 of file recursive_initialization.cpp.
| 
 | private | 
Construct a new parameter symbol of type param_type. 
| param_name | the base name for the new parameter | 
| param_type | type for the new symbol | 
Definition at line 579 of file recursive_initialization.cpp.
| 
 | private | 
Get the malloc function as symbol exprt, and inserts it into the goto-model if it doesn't exist already.
Definition at line 375 of file recursive_initialization.cpp.
| 
 | private | 
Recover the symbol expression from symbol table.
| symbol_name | the name of the symbol to get | 
Definition at line 598 of file recursive_initialization.cpp.
| void recursive_initializationt::initialize | ( | const exprt & | lhs, | 
| const exprt & | depth, | ||
| code_blockt & | body | ||
| ) | 
Generate initialisation code for lhs into body.
| lhs | The expression to initialise. | 
| depth | The number of pointer follows. Starts at 0. | 
| body | The code block to write initialisation code to. | 
Definition at line 138 of file recursive_initialization.cpp.
| 
 | private | 
Select the specified struct-member to be non-deterministically initialized.
| lhs | symbol expression of the top structure | 
| depth | only to be passed | 
| body | code block for the initializing assignment | 
| selection_spec | the user specification of the particular member to havoc | 
Definition at line 1057 of file recursive_initialization.cpp.
| 
 | private | 
Definition at line 412 of file recursive_initialization.cpp.
| 
 | inlinestatic | 
Definition at line 106 of file recursive_initialization.h.
| bool recursive_initializationt::needs_freeing | ( | const exprt & | expr | ) | const | 
Definition at line 924 of file recursive_initialization.cpp.
| 
 | private | 
Definition at line 392 of file recursive_initialization.cpp.
| 
 | private | 
Definition at line 428 of file recursive_initialization.cpp.
| 
 | private | 
Simple pretty-printer for typet.
Produces strings that can decorate variable names in C.
| type | type to be pretty-printed | 
Definition at line 605 of file recursive_initialization.cpp.
Definition at line 126 of file recursive_initialization.h.
| 
 | private | 
Definition at line 122 of file recursive_initialization.h.
| 
 | private | 
Definition at line 121 of file recursive_initialization.h.
| 
 | private | 
Definition at line 123 of file recursive_initialization.h.
| 
 | private | 
Definition at line 124 of file recursive_initialization.h.
| 
 | private | 
Definition at line 125 of file recursive_initialization.h.