@@ -278,10 +278,9 @@ void code_contractst::check_apply_loop_contracts(
278278 {
279279 code_assertt assertion{initial_invariant_val};
280280 assertion.add_source_location () = loop_head_location;
281+ assertion.add_source_location ().set_comment (
282+ " Check loop invariant before entry" );
281283 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" );
285284 }
286285
287286 // Insert the first block of pre_loop_head_instrs,
@@ -396,10 +395,9 @@ void code_contractst::check_apply_loop_contracts(
396395 {
397396 code_assertt assertion{invariant};
398397 assertion.add_source_location () = loop_head_location;
398+ assertion.add_source_location ().set_comment (
399+ " Check that loop invariant is preserved" );
399400 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" );
403401 }
404402
405403 // Generate: assignments to store the multidimensional decreases clause's
@@ -421,11 +419,10 @@ void code_contractst::check_apply_loop_contracts(
421419 generate_lexicographic_less_than_check (
422420 new_decreases_vars, old_decreases_vars)};
423421 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" );
424424 converter.goto_convert (
425425 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" );
429426
430427 // Discard the temporary variables that store decreases clause's value
431428 for (size_t i = 0 ; i < old_decreases_vars.size (); i++)
@@ -464,12 +461,12 @@ void code_contractst::check_apply_loop_contracts(
464461
465462 goto_programt pre_loop_exit_instrs;
466463 // 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" );
467467 pre_loop_exit_instrs.add (goto_programt::make_assertion (
468468 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));
473470 // Instructions to make all the temporaries go dead.
474471 pre_loop_exit_instrs.add (
475472 goto_programt::make_dead (in_base_case, loop_head_location));
@@ -873,9 +870,8 @@ void code_contractst::apply_function_contract(
873870 goto_programt::make_decl (to_symbol_expr (call_ret), loc));
874871
875872 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));
879875 }
880876
881877 // Insert havoc instructions immediately before the call site.
0 commit comments