@@ -278,10 +278,9 @@ void code_contractst::check_apply_loop_contracts(
278
278
{
279
279
code_assertt assertion{initial_invariant_val};
280
280
assertion.add_source_location () = loop_head_location;
281
+ assertion.add_source_location ().set_comment (
282
+ " Check loop invariant before entry" );
281
283
converter.goto_convert (assertion, pre_loop_head_instrs, mode);
282
- pre_loop_head_instrs.instructions .back ()
283
- .source_location_nonconst ()
284
- .set_comment (" Check loop invariant before entry" );
285
284
}
286
285
287
286
// Insert the first block of pre_loop_head_instrs,
@@ -396,10 +395,9 @@ void code_contractst::check_apply_loop_contracts(
396
395
{
397
396
code_assertt assertion{invariant};
398
397
assertion.add_source_location () = loop_head_location;
398
+ assertion.add_source_location ().set_comment (
399
+ " Check that loop invariant is preserved" );
399
400
converter.goto_convert (assertion, pre_loop_end_instrs, mode);
400
- pre_loop_end_instrs.instructions .back ()
401
- .source_location_nonconst ()
402
- .set_comment (" Check that loop invariant is preserved" );
403
401
}
404
402
405
403
// Generate: assignments to store the multidimensional decreases clause's
@@ -421,11 +419,10 @@ void code_contractst::check_apply_loop_contracts(
421
419
generate_lexicographic_less_than_check (
422
420
new_decreases_vars, old_decreases_vars)};
423
421
monotonic_decreasing_assertion.add_source_location () = loop_head_location;
422
+ monotonic_decreasing_assertion.add_source_location ().set_comment (
423
+ " Check decreases clause on loop iteration" );
424
424
converter.goto_convert (
425
425
monotonic_decreasing_assertion, pre_loop_end_instrs, mode);
426
- pre_loop_end_instrs.instructions .back ()
427
- .source_location_nonconst ()
428
- .set_comment (" Check decreases clause on loop iteration" );
429
426
430
427
// Discard the temporary variables that store decreases clause's value
431
428
for (size_t i = 0 ; i < old_decreases_vars.size (); i++)
@@ -464,12 +461,12 @@ void code_contractst::check_apply_loop_contracts(
464
461
465
462
goto_programt pre_loop_exit_instrs;
466
463
// Assertion to check that step case was checked if we entered the loop.
464
+ source_locationt annotated_location = loop_head_location;
465
+ annotated_location.set_comment (
466
+ " Check that loop instrumentation was not truncated" );
467
467
pre_loop_exit_instrs.add (goto_programt::make_assertion (
468
468
or_exprt{not_exprt{entered_loop}, not_exprt{in_base_case}},
469
- loop_head_location));
470
- pre_loop_exit_instrs.instructions .back ()
471
- .source_location_nonconst ()
472
- .set_comment (" Check that loop instrumentation was not truncated" );
469
+ annotated_location));
473
470
// Instructions to make all the temporaries go dead.
474
471
pre_loop_exit_instrs.add (
475
472
goto_programt::make_dead (in_base_case, loop_head_location));
@@ -873,9 +870,8 @@ void code_contractst::apply_function_contract(
873
870
goto_programt::make_decl (to_symbol_expr (call_ret), loc));
874
871
875
872
side_effect_expr_nondett expr (type, location);
876
- auto target = havoc_instructions.add (
877
- goto_programt::make_assignment (call_ret, expr, loc));
878
- target->code_nonconst ().add_source_location () = loc;
873
+ havoc_instructions.add (goto_programt::make_assignment (
874
+ code_assignt{call_ret, std::move (expr), loc}, loc));
879
875
}
880
876
881
877
// Insert havoc instructions immediately before the call site.
0 commit comments