@@ -69,15 +69,12 @@ static void check_apply_invariants(
69
69
PRECONDITION (!loop.empty ());
70
70
71
71
// find the last back edge
72
- goto_programt::targett loop_end=loop_head;
73
- for (loopt::const_iterator
74
- it=loop.begin ();
75
- it!=loop.end ();
76
- ++it)
77
- if ((*it)->is_goto () &&
78
- (*it)->get_target ()==loop_head &&
79
- (*it)->location_number >loop_end->location_number )
80
- loop_end=*it;
72
+ goto_programt::targett loop_end = loop_head;
73
+ for (const auto &t : loop)
74
+ if (
75
+ t->is_goto () && t->get_target () == loop_head &&
76
+ t->location_number > loop_end->location_number )
77
+ loop_end = t;
81
78
82
79
// see whether we have an invariant
83
80
exprt invariant = static_cast <const exprt &>(
@@ -107,7 +104,7 @@ static void check_apply_invariants(
107
104
{
108
105
goto_programt::targett a = havoc_code.add (
109
106
goto_programt::make_assertion (invariant, loop_head->source_location ));
110
- a->source_location .set_comment (" Loop invariant violated before entry" );
107
+ a->source_location .set_comment (" Check loop invariant before entry" );
111
108
}
112
109
113
110
// havoc variables being written to
@@ -125,15 +122,15 @@ static void check_apply_invariants(
125
122
side_effect_expr_nondett (bool_typet (), loop_head->source_location )));
126
123
}
127
124
128
- // Now havoc at the loop head. Use insert_swap to
129
- // preserve jumps to loop head.
125
+ // Now havoc at the loop head.
126
+ // Use insert_before_swap to preserve jumps to loop head.
130
127
goto_function.body .insert_before_swap (loop_head, havoc_code);
131
128
132
129
// assert the invariant at the end of the loop body
133
130
{
134
131
goto_programt::instructiont a =
135
132
goto_programt::make_assertion (invariant, loop_end->source_location );
136
- a.source_location .set_comment (" Loop invariant not preserved" );
133
+ a.source_location .set_comment (" Check that loop invariant is preserved" );
137
134
goto_function.body .insert_before_swap (loop_end, a);
138
135
++loop_end;
139
136
}
@@ -306,12 +303,9 @@ void code_contractst::apply_loop_contract(
306
303
natural_loops_mutablet natural_loops (goto_function.body );
307
304
308
305
// iterate over the (natural) loops in the function
309
- for (natural_loops_mutablet::loop_mapt::const_iterator l_it =
310
- natural_loops.loop_map .begin ();
311
- l_it != natural_loops.loop_map .end ();
312
- l_it++)
306
+ for (const auto &loop : natural_loops.loop_map )
313
307
check_apply_invariants (
314
- goto_function, local_may_alias, l_it-> first , l_it-> second );
308
+ goto_function, local_may_alias, loop. first , loop. second );
315
309
}
316
310
317
311
const symbolt &code_contractst::new_tmp_symbol (
@@ -959,7 +953,7 @@ bool code_contractst::enforce_contracts(
959
953
}
960
954
961
955
if (!fail)
962
- fail | = enforce_contract (fun);
956
+ fail = enforce_contract (fun);
963
957
}
964
958
return fail;
965
959
}
0 commit comments