Merge pull request #4151 from tautschnig/update-after-remove-returns

Update after remove returns
This commit is contained in:
Michael Tautschnig 2019-03-02 06:19:43 +00:00 committed by GitHub
commit ee11014382
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 17 deletions

View File

@ -448,10 +448,6 @@ int goto_instrument_parse_optionst::doit()
if(cmdline.isset("check-call-sequence"))
{
do_remove_returns();
// recalculate numbers, etc.
goto_model.goto_functions.update();
check_call_sequence(goto_model);
return CPROVER_EXIT_SUCCESS;
}
@ -1456,9 +1452,6 @@ void goto_instrument_parse_optionst::instrument_goto_program()
{
do_indirect_call_and_rtti_removal();
// recalculate numbers, etc.
goto_model.goto_functions.update();
status() << "Performing a reachability slice" << eom;
if(cmdline.isset("property"))
reachability_slicer(goto_model, cmdline.get_values("property"));
@ -1470,9 +1463,6 @@ void goto_instrument_parse_optionst::instrument_goto_program()
{
do_indirect_call_and_rtti_removal();
// recalculate numbers, etc.
goto_model.goto_functions.update();
status() << "Performing a function pointer reachability slice" << eom;
function_path_reachability_slicer(
goto_model, cmdline.get_comma_separated_values("fp-reachability-slice"));
@ -1484,9 +1474,6 @@ void goto_instrument_parse_optionst::instrument_goto_program()
do_indirect_call_and_rtti_removal();
do_remove_returns();
// recalculate numbers, etc.
goto_model.goto_functions.update();
status() << "Performing a full slice" << eom;
if(cmdline.isset("property"))
property_slicer(goto_model, cmdline.get_values("property"));

View File

@ -44,7 +44,7 @@ protected:
const irep_idt &function_id,
goto_functionst::goto_functiont &function);
void do_function_calls(
bool do_function_calls(
function_is_stubt function_is_stub,
goto_programt &goto_program);
@ -142,10 +142,14 @@ void remove_returnst::replace_returns(
/// \param function_is_stub: function (irep_idt -> bool) that determines whether
/// a given function ID is a stub
/// \param goto_program: program to transform
void remove_returnst::do_function_calls(
/// \return True if, and only if, instructions have been inserted. In that case
/// the caller must invoke an appropriate method to update location numbers.
bool remove_returnst::do_function_calls(
function_is_stubt function_is_stub,
goto_programt &goto_program)
{
bool requires_update = false;
Forall_goto_program_instructions(i_it, goto_program)
{
if(i_it->is_function_call())
@ -221,6 +225,8 @@ void remove_returnst::do_function_calls(
t_a,
goto_programt::make_dead(*return_value, i_it->source_location));
}
requires_update = true;
}
// update the call
@ -228,6 +234,8 @@ void remove_returnst::do_function_calls(
}
}
}
return requires_update;
}
void remove_returnst::operator()(goto_functionst &goto_functions)
@ -244,7 +252,8 @@ void remove_returnst::operator()(goto_functionst &goto_functions)
};
replace_returns(it->first, it->second);
do_function_calls(function_is_stub, it->second.body);
if(do_function_calls(function_is_stub, it->second.body))
goto_functions.compute_location_numbers(it->second.body);
}
}
@ -261,7 +270,8 @@ void remove_returnst::operator()(
return;
replace_returns(model_function.get_function_id(), goto_function);
do_function_calls(function_is_stub, goto_function.body);
if(do_function_calls(function_is_stub, goto_function.body))
model_function.compute_location_numbers();
}
/// removes returns