Skip to content

Remove unused parameters in goto_convert #2457

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions src/goto-programs/builtin_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,6 @@ void goto_convertt::do_scanf(
}

void goto_convertt::do_input(
const exprt &lhs,
const exprt &function,
const exprt::operandst &arguments,
goto_programt &dest)
Expand All @@ -341,7 +340,6 @@ void goto_convertt::do_input(
}

void goto_convertt::do_output(
const exprt &lhs,
const exprt &function,
const exprt::operandst &arguments,
goto_programt &dest)
Expand Down Expand Up @@ -846,12 +844,26 @@ void goto_convertt::do_function_call_symbol(
else if(identifier==CPROVER_PREFIX "input" ||
identifier=="__CPROVER::input")
{
do_input(lhs, function, arguments, dest);
if(lhs.is_not_nil())
{
error().source_location=function.find_source_location();
error() << identifier << " expected not to have LHS" << eom;
throw 0;
}

do_input(function, arguments, dest);
}
else if(identifier==CPROVER_PREFIX "output" ||
identifier=="__CPROVER::output")
{
do_output(lhs, function, arguments, dest);
if(lhs.is_not_nil())
{
error().source_location=function.find_source_location();
error() << identifier << " expected not to have LHS" << eom;
throw 0;
}

do_output(function, arguments, dest);
}
else if(identifier==CPROVER_PREFIX "atomic_begin" ||
identifier=="__CPROVER::atomic_begin" ||
Expand Down
8 changes: 2 additions & 6 deletions src/goto-programs/goto_convert_class.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,15 @@ class goto_convertt:public messaget
bool result_is_used);
void remove_cpp_delete(
side_effect_exprt &expr,
goto_programt &dest,
bool result_is_used);
goto_programt &dest);
void remove_malloc(
side_effect_exprt &expr,
goto_programt &dest,
const irep_idt &mode,
bool result_is_used);
void remove_temporary_object(
side_effect_exprt &expr,
goto_programt &dest,
bool result_is_used);
goto_programt &dest);
void remove_statement_expression(
side_effect_exprt &expr,
goto_programt &dest,
Expand Down Expand Up @@ -631,12 +629,10 @@ class goto_convertt:public messaget
const exprt::operandst &arguments,
goto_programt &dest);
void do_input(
const exprt &lhs,
const exprt &rhs,
const exprt::operandst &arguments,
goto_programt &dest);
void do_output(
const exprt &lhs,
const exprt &rhs,
const exprt::operandst &arguments,
goto_programt &dest);
Expand Down
10 changes: 4 additions & 6 deletions src/goto-programs/goto_convert_side_effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -452,8 +452,7 @@ void goto_convertt::remove_cpp_new(

void goto_convertt::remove_cpp_delete(
side_effect_exprt &expr,
goto_programt &dest,
bool result_is_used)
goto_programt &dest)
{
assert(expr.operands().size()==1);

Expand Down Expand Up @@ -507,8 +506,7 @@ void goto_convertt::remove_malloc(

void goto_convertt::remove_temporary_object(
side_effect_exprt &expr,
goto_programt &dest,
bool result_is_used)
goto_programt &dest)
{
const irep_idt &mode = expr.get(ID_mode);
if(expr.operands().size()!=1 &&
Expand Down Expand Up @@ -666,11 +664,11 @@ void goto_convertt::remove_side_effect(
remove_cpp_new(expr, dest, result_is_used);
else if(statement==ID_cpp_delete ||
statement==ID_cpp_delete_array)
remove_cpp_delete(expr, dest, result_is_used);
remove_cpp_delete(expr, dest);
else if(statement==ID_allocate)
remove_malloc(expr, dest, mode, result_is_used);
else if(statement==ID_temporary_object)
remove_temporary_object(expr, dest, result_is_used);
remove_temporary_object(expr, dest);
else if(statement==ID_statement_expression)
remove_statement_expression(expr, dest, mode, result_is_used);
else if(statement==ID_nondet)
Expand Down
4 changes: 1 addition & 3 deletions src/goto-programs/parameter_assignments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ class parameter_assignmentst
symbol_tablet &symbol_table;

void do_function_calls(
goto_functionst &goto_functions,
goto_programt &goto_program);
};

/// turns x=f(...) into f(...); lhs=f#return_value;
void parameter_assignmentst::do_function_calls(
goto_functionst &goto_functions,
goto_programt &goto_program)
{
Forall_goto_program_instructions(i_it, goto_program)
Expand Down Expand Up @@ -93,7 +91,7 @@ void parameter_assignmentst::do_function_calls(
void parameter_assignmentst::operator()(goto_functionst &goto_functions)
{
Forall_goto_functions(it, goto_functions)
do_function_calls(goto_functions, it->second.body);
do_function_calls(it->second.body);
}

/// removes returns
Expand Down
4 changes: 1 addition & 3 deletions src/goto-programs/remove_returns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ class remove_returnst
goto_functionst::function_mapt::iterator f_it);

void undo_function_calls(
goto_functionst &goto_functions,
goto_programt &goto_program);

symbol_exprt get_or_create_return_value_symbol(const irep_idt &function_id);
Expand Down Expand Up @@ -366,7 +365,6 @@ bool remove_returnst::restore_returns(

/// turns f(...); lhs=f#return_value; into lhs=f(...)
void remove_returnst::undo_function_calls(
goto_functionst &goto_functions,
goto_programt &goto_program)
{
namespacet ns(symbol_table);
Expand Down Expand Up @@ -436,7 +434,7 @@ void remove_returnst::restore(goto_functionst &goto_functions)
if(!unmodified)
{
Forall_goto_functions(it, goto_functions)
undo_function_calls(goto_functions, it->second.body);
undo_function_calls(it->second.body);
}
}

Expand Down