9 #ifndef CPROVER_GOTO_HARNESS_RECURSIVE_INITIALIZATION_H
10 #define CPROVER_GOTO_HARNESS_RECURSIVE_INITIALIZATION_H
20 #include <unordered_set>
25 #define GOTO_HARNESS_PREFIX "__GOTO_HARNESS"
56 const std::string &option,
57 const std::list<std::string> &values);
134 std::optional<equal_cluster_idt>
137 std::optional<irep_idt>
148 const std::string &symbol_name,
149 const exprt &initial_value)
const;
166 const std::string &symbol_name,
167 const typet &type)
const;
181 const std::string ¶m_name,
182 const typet ¶m_type);
203 const exprt &depth_symbol,
205 const std::optional<exprt> &size_symbol,
206 const std::optional<irep_idt> &lhs_name,
207 const bool is_nullable);
264 const std::optional<irep_idt> &lhs_name);
277 const std::vector<irep_idt> &selection_spec);
std::string array_name(const namespacet &ns, const exprt &expr)
static symbolt result_symbol(const irep_idt &identifier, const typet &type, const source_locationt &source_location, symbol_table_baset &symbol_table)
A codet representing sequential composition of program statements.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
bool get_bool(const irep_idt &name) const
const irep_idt & id() const
Class for generating initialisation code for compound structures.
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.
std::string type2id(const typet &type) const
Simple pretty-printer for typet.
void free_if_possible(const exprt &expr, code_blockt &body)
type_constructor_namest type_constructor_names
code_blockt build_dynamic_array_constructor(const exprt &depth, const symbol_exprt &result, const exprt &size, const std::optional< irep_idt > &lhs_name)
Constructor for dynamic arrays: allocate memory for n elements (n is random but bounded) and initiali...
code_blockt build_constructor_body(const exprt &depth_symbol, const symbol_exprt &result_symbol, const std::optional< exprt > &size_symbol, const std::optional< irep_idt > &lhs_name, const bool is_nullable)
Case analysis for which constructor should be used.
std::vector< std::optional< exprt > > common_arguments_origins
code_blockt build_nondet_constructor(const symbol_exprt &result) const
Default constructor: assigns non-deterministic value of the right type.
symbol_exprt get_malloc_function()
Get the malloc function as symbol exprt, and inserts it into the goto-model if it doesn't exist alrea...
std::optional< equal_cluster_idt > find_equal_cluster(const irep_idt &name) const
code_blockt build_struct_constructor(const exprt &depth, const symbol_exprt &result)
Constructor for structures: simply iterates over members and initialise each one.
irep_idt build_constructor(const exprt &expr)
Check if a constructor for the type of expr already exists and create it if not.
irep_idt max_depth_var_name
irep_idt get_fresh_global_name(const std::string &symbol_name, const exprt &initial_value) const
Construct a new global symbol of type int and set it's value to initial_value.
code_blockt build_function_pointer_constructor(const symbol_exprt &result, bool is_nullable)
Constructor for function pointers.
const recursive_initialization_configt initialization_config
irep_idt min_depth_var_name
symbol_exprt get_fresh_local_typed_symexpr(const std::string &symbol_name, const typet &type) const
Construct a new local symbol of type type initialised to init_value.
static bool is_initialization_allowed(const symbolt &symbol)
std::optional< irep_idt > get_associated_size_variable(const irep_idt &array_name) const
code_blockt build_array_constructor(const exprt &depth, const symbol_exprt &result)
Constructor for arrays: simply iterates over elements and initialise each one.
recursive_initializationt(recursive_initialization_configt initialization_config, goto_modelt &goto_model)
std::map< constructor_keyt, irep_idt > type_constructor_namest
std::size_t equal_cluster_idt
std::set< irep_idt > recursion_sett
void free_cluster_origins(code_blockt &body)
bool should_be_treated_as_array(const irep_idt &pointer_name) const
void initialize(const exprt &lhs, const exprt &depth, code_blockt &body)
Generate initialisation code for lhs into body.
symbol_exprt get_free_function()
Get the free function as symbol expression, and inserts it into the goto-model if it doesn't exist al...
bool needs_freeing(const exprt &expr) const
const symbolt & get_fresh_fun_symbol(const std::string &fun_name, const typet &fun_type)
Construct a new function symbol of type fun_type.
bool should_be_treated_as_cstring(const irep_idt &pointer_name) const
symbol_exprt get_fresh_local_symexpr(const std::string &symbol_name) const
Construct a new local symbol of type int initialised to 0.
bool is_array_size_parameter(const irep_idt &cmdline_arg) const
symbol_exprt get_symbol_expr(const irep_idt &symbol_name) const
Recover the symbol expression from symbol table.
symbol_exprt get_fresh_global_symexpr(const std::string &symbol_name) const
Construct a new global symbol of type int initialised to 0.
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...
symbolt & get_fresh_param_symbol(const std::string ¶m_name, const typet ¶m_type)
Construct a new parameter symbol of type param_type.
Expression to hold a symbol (variable)
typet type
Type of symbol.
irep_idt name
The unique identifier.
The type of an expression, extends irept.
bool has_prefix(const std::string &s, const std::string &prefix)
const std::string & id2string(const irep_idt &d)
#define GOTO_HARNESS_PREFIX
API to expression classes.
std::set< irep_idt > pointers_to_treat_as_cstrings
std::vector< std::set< irep_idt > > pointers_to_treat_equal
std::map< irep_idt, irep_idt > array_name_to_associated_array_size_variable
bool handle_option(const std::string &option, const std::list< std::string > &values)
Parse the options specific for recursive initialisation.
std::vector< std::vector< irep_idt > > selection_specs
bool arguments_may_be_equal
std::size_t max_dynamic_array_size
std::set< irep_idt > variables_that_hold_array_sizes
std::size_t max_nondet_tree_depth
std::set< irep_idt > pointers_to_treat_as_arrays
std::size_t min_null_tree_depth
std::size_t min_dynamic_array_size
std::string to_string() const
std::unordered_set< irep_idt > potential_null_function_pointers
bool operator==(const constructor_keyt &other) const
bool operator<(const constructor_keyt &other) const