Skip to content

Add array initialisation support in default goto-harness. #4234

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/goto-harness/recursive_initialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,36 @@ void recursive_initializationt::initialize_dynamic_array(

body.add(code_assignt{pointer, index_exprt{arrays, nondet_index}});
}

std::string recursive_initialization_configt::to_string() const
{
std::ostringstream out{};
out << "recursive_initialization_config {"
<< "\n min_null_tree_depth = " << min_null_tree_depth
<< "\n max_nondet_tree_depth = " << max_nondet_tree_depth
<< "\n mode = " << mode
<< "\n max_dynamic_array_size = " << max_dynamic_array_size
<< "\n min_dynamic_array_size = " << min_dynamic_array_size
<< "\n pointers_to_treat_as_arrays = [";
for(auto const &pointer : pointers_to_treat_as_arrays)
{
out << "\n " << pointer;
}
out << "\n ]"
<< "\n variables_that_hold_array_sizes = [";
for(auto const &array_size : variables_that_hold_array_sizes)
{
out << "\n " << array_size;
}
out << "\n ]";
out << "\n array_name_to_associated_size_variable = [";
for(auto const &associated_array_size :
array_name_to_associated_array_size_variable)
{
out << "\n " << associated_array_size.first << " -> "
<< associated_array_size.second;
}
out << "\n ]";
out << "\n}";
return out.str();
}
2 changes: 2 additions & 0 deletions src/goto-harness/recursive_initialization.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ struct recursive_initialization_configt
std::set<irep_idt> pointers_to_treat_as_arrays;
std::set<irep_idt> variables_that_hold_array_sizes;
std::map<irep_idt, irep_idt> array_name_to_associated_array_size_variable;

std::string to_string() const; // for debugging purposes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If to_string() is only meant to be used for debugging purposes, is it worth wrapping it in #if DEBUG ?

};

/// Class for generating initialisation code
Expand Down