Skip to content

Commit 2a9e3e2

Browse files
committed
minor improvements to assigns clause checking
1 parent cec18ba commit 2a9e3e2

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

src/goto-instrument/contracts/contracts.cpp

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,7 @@ void code_contractst::check_apply_loop_contracts(
179179
}
180180
else
181181
{
182-
for(const auto &target : assigns.operands())
183-
modifies.insert(target);
182+
modifies.insert(assigns.operands().cbegin(), assigns.operands().cend());
184183

185184
// Create snapshots of write set CARs.
186185
// This must be done before havocing the write set.
@@ -269,16 +268,10 @@ void code_contractst::check_apply_loop_contracts(
269268
loop_head--;
270269

271270
// Perform write set instrumentation before adding anything else to loop body.
272-
// Copy the loop_body as we would increment the iterator while instrumenting.
273271
if(assigns.is_not_nil())
274272
{
275-
auto copy_loop_body = loop_body;
276273
check_frame_conditions(
277-
function_name,
278-
goto_function.body,
279-
copy_loop_body,
280-
loop_end,
281-
loop_assigns);
274+
function_name, goto_function.body, loop_body, loop_end, loop_assigns);
282275
}
283276

284277
// Generate: assignments to store the multidimensional decreases clause's
@@ -654,8 +647,7 @@ bool code_contractst::apply_function_contract(
654647

655648
// Havoc all targets in the write set
656649
modifiest modifies;
657-
for(const auto &target : targets.operands())
658-
modifies.insert(target);
650+
modifies.insert(targets.operands().cbegin(), targets.operands().cend());
659651

660652
goto_programt assigns_havoc;
661653
havoc_assigns_targetst havoc_gen(modifies, ns);
@@ -1014,7 +1006,7 @@ bool code_contractst::check_frame_conditions_function(const irep_idt &function)
10141006
void code_contractst::check_frame_conditions(
10151007
const irep_idt &function,
10161008
goto_programt &body,
1017-
goto_programt::targett &instruction_it,
1009+
goto_programt::targett instruction_it,
10181010
const goto_programt::targett &instruction_end,
10191011
assigns_clauset &assigns)
10201012
{

src/goto-instrument/contracts/contracts.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class code_contractst
131131
void check_frame_conditions(
132132
const irep_idt &,
133133
goto_programt &,
134-
goto_programt::targett &,
134+
goto_programt::targett,
135135
const goto_programt::targett &,
136136
assigns_clauset &);
137137

0 commit comments

Comments
 (0)