Skip to content

Commit 126aaaa

Browse files
authored
Merge pull request diffblue#4001 from diffblue/use_make_X2
Use goto_programt::make_X factories in remove_returns
2 parents abbb389 + aa85fb2 commit 126aaaa

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/goto-programs/goto_program.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,14 @@ class goto_programt
573573
return instructions.insert(target, instructiont());
574574
}
575575

576+
/// Insertion before the instruction pointed-to by the given instruction
577+
/// iterator `target`.
578+
/// \return newly inserted location
579+
targett insert_before(const_targett target, const instructiont &i)
580+
{
581+
return instructions.insert(target, i);
582+
}
583+
576584
/// Insertion after the instruction pointed-to by the given instruction
577585
/// iterator `target`.
578586
/// \return newly inserted location
@@ -581,6 +589,14 @@ class goto_programt
581589
return instructions.insert(std::next(target), instructiont());
582590
}
583591

592+
/// Insertion after the instruction pointed-to by the given instruction
593+
/// iterator `target`.
594+
/// \return newly inserted location
595+
targett insert_after(const_targett target, const instructiont &i)
596+
{
597+
return instructions.insert(std::next(target), i);
598+
}
599+
584600
/// Appends the given program `p` to `*this`. `p` is destroyed.
585601
void destructive_append(goto_programt &p)
586602
{

src/goto-programs/remove_returns.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -206,20 +206,19 @@ void remove_returnst::do_function_calls(
206206
rhs = side_effect_expr_nondett(
207207
function_call.lhs().type(), i_it->source_location);
208208

209-
goto_programt::targett t_a=goto_program.insert_after(i_it);
210-
t_a->make_assignment();
211-
t_a->source_location=i_it->source_location;
212-
t_a->code=code_assignt(function_call.lhs(), rhs);
209+
goto_programt::targett t_a = goto_program.insert_after(
210+
i_it,
211+
goto_programt::make_assignment(
212+
code_assignt(function_call.lhs(), rhs), i_it->source_location));
213213

214214
// fry the previous assignment
215215
function_call.lhs().make_nil();
216216

217217
if(!is_stub)
218218
{
219-
goto_programt::targett t_d=goto_program.insert_after(t_a);
220-
t_d->make_dead();
221-
t_d->source_location=i_it->source_location;
222-
t_d->code = code_deadt(*return_value);
219+
goto_program.insert_after(
220+
t_a,
221+
goto_programt::make_dead(*return_value, i_it->source_location));
223222
}
224223
}
225224
}

0 commit comments

Comments
 (0)