@@ -87,20 +87,26 @@ bool recursive_initialization_configt::handle_option(
87
87
[](const std::string &opt) -> irep_idt { return irep_idt{opt}; });
88
88
return true ;
89
89
}
90
- else if (option == COMMON_HARNESS_GENERATOR_MEMBER_SELECTION_OPT )
90
+ else if (option == COMMON_HARNESS_GENERATOR_HAVOC_MEMBER_OPT )
91
91
{
92
- auto selection_spec_strings = split_string (
92
+ const auto list_of_members_string =
93
93
harness_options_parser::require_exactly_one_value (
94
- COMMON_HARNESS_GENERATOR_MEMBER_SELECTION_OPT, values),
95
- ' .' );
96
-
97
- std::transform (
98
- selection_spec_strings.begin (),
99
- selection_spec_strings.end (),
100
- std::back_inserter (selection_spec),
101
- [](const std::string &member_name_string) {
102
- return irep_idt{member_name_string};
103
- });
94
+ COMMON_HARNESS_GENERATOR_HAVOC_MEMBER_OPT, values);
95
+ const auto list_of_members = split_string (list_of_members_string, ' ,' );
96
+ for (const auto &member : list_of_members)
97
+ {
98
+ const auto selection_spec_strings = split_string (member, ' .' );
99
+
100
+ selection_specs.push_back ({});
101
+ auto &selection_spec = selection_specs.back ();
102
+ std::transform (
103
+ selection_spec_strings.begin (),
104
+ selection_spec_strings.end (),
105
+ std::back_inserter (selection_spec),
106
+ [](const std::string &member_name_string) {
107
+ return irep_idt{member_name_string};
108
+ });
109
+ }
104
110
return true ;
105
111
}
106
112
return false ;
@@ -131,20 +137,22 @@ void recursive_initializationt::initialize(
131
137
const exprt &depth,
132
138
code_blockt &body)
133
139
{
134
- if (
135
- lhs.id () == ID_symbol && !initialization_config.selection_spec .empty () &&
136
- initialization_config.selection_spec .front () ==
137
- to_symbol_expr (lhs).get_identifier ())
140
+ if (lhs.id () == ID_symbol && !initialization_config.selection_specs .empty ())
138
141
{
139
- initialize_selected_member (lhs, depth, body);
140
- return ;
142
+ auto lhs_id = to_symbol_expr (lhs).get_identifier ();
143
+ for (const auto &selection_spec : initialization_config.selection_specs )
144
+ {
145
+ if (selection_spec.front () == lhs_id)
146
+ {
147
+ initialize_selected_member (lhs, depth, body, selection_spec);
148
+ return ;
149
+ }
150
+ }
141
151
}
142
152
// special handling for the case that pointer arguments should be treated
143
153
// equal: if the equality is enforced (rather than the pointers may be equal),
144
154
// then we don't even build the constructor functions
145
- if (
146
- lhs.id () == ID_symbol &&
147
- should_be_treated_equal (to_symbol_expr (lhs).get_identifier ()))
155
+ if (lhs.id () == ID_symbol)
148
156
{
149
157
const auto maybe_cluster_index =
150
158
find_equal_cluster (to_symbol_expr (lhs).get_identifier ());
@@ -987,24 +995,23 @@ code_blockt recursive_initializationt::build_function_pointer_constructor(
987
995
void recursive_initializationt::initialize_selected_member (
988
996
const exprt &lhs,
989
997
const exprt &depth,
990
- code_blockt &body)
998
+ code_blockt &body,
999
+ const std::vector<irep_idt> &selection_spec)
991
1000
{
992
1001
PRECONDITION (lhs.id () == ID_symbol);
993
1002
PRECONDITION (lhs.type ().id () == ID_struct_tag);
994
- PRECONDITION (!initialization_config. selection_spec .empty ());
1003
+ PRECONDITION (!selection_spec.empty ());
995
1004
996
1005
auto component_member = lhs;
997
1006
const namespacet ns{goto_model.symbol_table };
998
1007
999
- for (auto it = initialization_config.selection_spec .begin () + 1 ;
1000
- it != initialization_config.selection_spec .end ();
1001
- it++)
1008
+ for (auto it = selection_spec.begin () + 1 ; it != selection_spec.end (); it++)
1002
1009
{
1003
1010
if (component_member.type ().id () != ID_struct_tag)
1004
1011
{
1005
1012
throw invalid_command_line_argument_exceptiont{
1006
1013
" '" + id2string (*it) + " ' is not a component name" ,
1007
- " --" COMMON_HARNESS_GENERATOR_MEMBER_SELECTION_OPT };
1014
+ " --" COMMON_HARNESS_GENERATOR_HAVOC_MEMBER_OPT };
1008
1015
}
1009
1016
const auto &struct_tag_type = to_struct_tag_type (component_member.type ());
1010
1017
const auto &struct_type = to_struct_type (ns.follow_tag (struct_tag_type));
@@ -1027,7 +1034,7 @@ void recursive_initializationt::initialize_selected_member(
1027
1034
{
1028
1035
throw invalid_command_line_argument_exceptiont{
1029
1036
" '" + id2string (*it) + " ' is not a component name" ,
1030
- " --" COMMON_HARNESS_GENERATOR_MEMBER_SELECTION_OPT };
1037
+ " --" COMMON_HARNESS_GENERATOR_HAVOC_MEMBER_OPT };
1031
1038
}
1032
1039
}
1033
1040
initialize (component_member, depth, body);
0 commit comments