29
29
// / \param target: One of the steps in that goto program.
30
30
// / \param symbol_table: The global symbol table.
31
31
// / \param message_handler: Handles logging.
32
- // / \param max_nondet_array_length: Maximum size of new nondet arrays.
33
- // / \return The next instruction to process with this function.
34
- static goto_programt::targett insert_nondet_init_code (
32
+ // / \param object_factory_parameters: Parameters for the generation of nondet
33
+ // / objects.
34
+ // / \return The next instruction to process with this function and a boolean
35
+ // / indicating whether any changes were made to the goto program.
36
+ static std::pair<goto_programt::targett, bool > insert_nondet_init_code (
35
37
goto_programt &goto_program,
36
38
const goto_programt::targett &target,
37
39
symbol_table_baset &symbol_table,
@@ -40,6 +42,7 @@ static goto_programt::targett insert_nondet_init_code(
40
42
const irep_idt &mode)
41
43
{
42
44
const auto next_instr = std::next (target);
45
+ bool changed = false ;
43
46
44
47
// We only expect to find nondets in the rhs of an assignments or in return
45
48
// statements
@@ -132,9 +135,11 @@ static goto_programt::targett insert_nondet_init_code(
132
135
// Finally insert the dead instruction for aux_symbol after target
133
136
goto_program.insert_after (target)->swap (
134
137
aux_instructions.instructions .back ());
138
+
139
+ changed = true ;
135
140
}
136
141
137
- return next_instr;
142
+ return std::make_pair ( next_instr, changed) ;
138
143
}
139
144
140
145
// / For each instruction in the goto program, checks if it is an assignment from
@@ -151,20 +156,27 @@ void convert_nondet(
151
156
const object_factory_parameterst &object_factory_parameters,
152
157
const irep_idt &mode)
153
158
{
154
- for (auto instruction_iterator=goto_program.instructions .begin (),
155
- end=goto_program.instructions .end ();
156
- instruction_iterator!=end;)
159
+ bool changed = false ;
160
+ auto instruction_iterator = goto_program.instructions .begin ();
161
+ auto end = goto_program.instructions .end ();
162
+
163
+ while (instruction_iterator != end)
157
164
{
158
- instruction_iterator = insert_nondet_init_code (
165
+ auto ret = insert_nondet_init_code (
159
166
goto_program,
160
167
instruction_iterator,
161
168
symbol_table,
162
169
message_handler,
163
170
object_factory_parameters,
164
171
mode);
172
+ instruction_iterator = ret.first ;
173
+ changed |= ret.second ;
165
174
}
166
175
167
- goto_program.update ();
176
+ if (changed)
177
+ {
178
+ goto_program.update ();
179
+ }
168
180
}
169
181
170
182
void convert_nondet (
0 commit comments