9
9
#include " goto-programs/replace_java_nondet.h"
10
10
#include " goto-programs/goto_convert.h"
11
11
#include " goto-programs/goto_model.h"
12
+ #include " goto-programs/remove_skip.h"
12
13
13
14
#include " util/irep_ids.h"
14
15
@@ -215,9 +216,9 @@ Function: check_and_replace_target
215
216
216
217
\*******************************************************************/
217
218
218
- static goto_programt::const_targett check_and_replace_target (
219
+ static goto_programt::targett check_and_replace_target (
219
220
goto_programt &goto_program,
220
- const goto_programt::const_targett &target)
221
+ const goto_programt::targett &target)
221
222
{
222
223
// Check whether this is a nondet library method, and return if not
223
224
const auto instr_info=get_nondet_instruction_info (target);
@@ -241,7 +242,7 @@ static goto_programt::const_targett check_and_replace_target(
241
242
to_symbol_expr (next_instr_assign_lhs).get_identifier ();
242
243
243
244
auto &instructions=goto_program.instructions ;
244
- const auto end=instructions.cend ();
245
+ const auto end=instructions.end ();
245
246
246
247
// Look for an instruction where this name is on the RHS of an assignment
247
248
const auto matching_assignment=std::find_if (
@@ -263,10 +264,15 @@ static goto_programt::const_targett check_and_replace_target(
263
264
const auto after_matching_assignment=std::next (matching_assignment);
264
265
assert (after_matching_assignment!=end);
265
266
266
- const auto after_erased=goto_program.instructions .erase (
267
- target, after_matching_assignment);
267
+ std::for_each (
268
+ target,
269
+ after_matching_assignment,
270
+ [](goto_programt::instructiont &instr)
271
+ {
272
+ instr.make_skip ();
273
+ });
268
274
269
- const auto inserted=goto_program.insert_before (after_erased );
275
+ const auto inserted=goto_program.insert_before (after_matching_assignment );
270
276
inserted->make_assignment ();
271
277
side_effect_expr_nondett inserted_expr (nondet_var.type ());
272
278
inserted_expr.set_nullable (
@@ -278,7 +284,7 @@ static goto_programt::const_targett check_and_replace_target(
278
284
279
285
goto_program.update ();
280
286
281
- return after_erased ;
287
+ return after_matching_assignment ;
282
288
}
283
289
284
290
/* ******************************************************************\
@@ -297,8 +303,8 @@ Function: replace_java_nondet
297
303
298
304
static void replace_java_nondet (goto_programt &goto_program)
299
305
{
300
- for (auto instruction_iterator=goto_program.instructions .cbegin (),
301
- end=goto_program.instructions .cend ();
306
+ for (auto instruction_iterator=goto_program.instructions .begin (),
307
+ end=goto_program.instructions .end ();
302
308
instruction_iterator!=end;)
303
309
{
304
310
instruction_iterator=check_and_replace_target (
@@ -315,5 +321,8 @@ void replace_java_nondet(goto_functionst &goto_functions)
315
321
{
316
322
replace_java_nondet (goto_program.second .body );
317
323
}
324
+
318
325
goto_functions.compute_location_numbers ();
326
+
327
+ remove_skip (goto_functions);
319
328
}
0 commit comments