Skip to content

added three constructors to code_function_callt #2841

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
Aug 30, 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
4 changes: 1 addition & 3 deletions src/analyses/escape_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,7 @@ void escape_analysist::insert_cleanup(
const code_typet &function_type=to_code_type(function.type());

goto_function.body.insert_before_swap(location);
code_function_callt code;
code.lhs().make_nil();
code.function()=function;
code_function_callt code(function);
code.function().add_source_location()=source_location;

if(function_type.parameters().size()==1)
Expand Down
7 changes: 2 additions & 5 deletions src/ansi-c/ansi_c_entry_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,16 @@ bool generate_ansi_c_start_function(
return true;
}

code_function_callt call_init;
call_init.lhs().make_nil();
code_function_callt call_init(init_it->second.symbol_expr());
call_init.add_source_location()=symbol.location;
call_init.function()=init_it->second.symbol_expr();

init_code.move_to_operands(call_init);
}

// build call to main function

code_function_callt call_main;
code_function_callt call_main(symbol.symbol_expr());
call_main.add_source_location()=symbol.location;
call_main.function()=symbol.symbol_expr();
call_main.function().add_source_location()=symbol.location;

if(to_code_type(symbol.type).return_type()!=empty_typet())
Expand Down
3 changes: 1 addition & 2 deletions src/goto-instrument/code_contracts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,7 @@ void code_contractst::add_contract_check(
g->source_location=skip->source_location;

// prepare function call including all declarations
code_function_callt call;
call.function()=ns.lookup(function).symbol_expr();
code_function_callt call(ns.lookup(function).symbol_expr());
replace_symbolt replace;

// decl ret
Expand Down
16 changes: 6 additions & 10 deletions src/goto-instrument/function.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,13 @@ code_function_callt function_to_call(

string_constantt function_id_string(argument);

code_function_callt call;
call.lhs().make_nil();
call.function()=
symbol_exprt(s_it->second.name, s_it->second.type);
call.arguments().resize(1);
call.arguments()[0]=
typecast_exprt(
code_function_callt call(
nil_exprt(),
symbol_exprt(s_it->second.name, s_it->second.type),
{typecast_exprt(
address_of_exprt(
index_exprt(
function_id_string, from_integer(0, index_type()))),
to_code_type(s_it->second.type).parameters()[0].type());
index_exprt(function_id_string, from_integer(0, index_type()))),
to_code_type(s_it->second.type).parameters()[0].type())});

return call;
}
Expand Down
10 changes: 4 additions & 6 deletions src/goto-instrument/goto_program2code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,11 @@ goto_programt::const_targett goto_program2codet::convert_instruction(
case ATOMIC_BEGIN:
case ATOMIC_END:
{
code_function_callt f;
const code_typet void_t({}, empty_typet());
f.function()=symbol_exprt(
target->is_atomic_begin() ?
"__CPROVER_atomic_begin" :
"__CPROVER_atomic_end",
void_t);
code_function_callt f(symbol_exprt(
target->is_atomic_begin() ? "__CPROVER_atomic_begin"
: "__CPROVER_atomic_end",
void_t));
dest.move_to_operands(f);
return target;
}
Expand Down
21 changes: 5 additions & 16 deletions src/goto-programs/builtin_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -309,10 +309,7 @@ void goto_convertt::do_scanf(
else
{
// we'll just do nothing
code_function_callt function_call;
function_call.lhs()=lhs;
function_call.function()=function;
function_call.arguments()=arguments;
code_function_callt function_call(lhs, function, arguments);
function_call.add_source_location()=function.source_location();

copy(function_call, FUNCTION_CALL, dest);
Expand Down Expand Up @@ -462,8 +459,7 @@ void goto_convertt::do_cpp_new(

tmp_symbol_expr=tmp_symbol.symbol_expr();

code_function_callt new_call;
new_call.function()=new_symbol;
code_function_callt new_call(new_symbol);
if(new_array)
new_call.arguments().push_back(count);
new_call.arguments().push_back(object_size);
Expand Down Expand Up @@ -493,8 +489,7 @@ void goto_convertt::do_cpp_new(

tmp_symbol_expr=tmp_symbol.symbol_expr();

code_function_callt new_call;
new_call.function()=new_symbol;
code_function_callt new_call(new_symbol);
if(new_array)
new_call.arguments().push_back(count);
new_call.arguments().push_back(object_size);
Expand Down Expand Up @@ -1552,10 +1547,7 @@ void goto_convertt::do_function_call_symbol(
new_function.set_identifier(name);
new_function.type()=f_type;

code_function_callt function_call;
function_call.lhs()=lhs;
function_call.function()=new_function;
function_call.arguments()=new_arguments;
code_function_callt function_call(lhs, new_function, new_arguments);
function_call.add_source_location()=function.source_location();

if(!symbol_table.has_symbol(name))
Expand All @@ -1575,10 +1567,7 @@ void goto_convertt::do_function_call_symbol(
do_function_call_symbol(*symbol);

// insert function call
code_function_callt function_call;
function_call.lhs()=lhs;
function_call.function()=function;
function_call.arguments()=arguments;
code_function_callt function_call(lhs, function, arguments);
function_call.add_source_location()=function.source_location();

copy(function_call, FUNCTION_CALL, dest);
Expand Down
6 changes: 1 addition & 5 deletions src/goto-programs/destructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ code_function_callt get_destructor(
ns.follow(arg_type.subtype())==type)
{
const symbol_exprt symbol_expr(it->get(ID_name), it->type());

code_function_callt function_call;
function_call.function()=symbol_expr;

return function_call;
return code_function_callt(symbol_expr);
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions src/goto-programs/goto_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -897,9 +897,8 @@ void goto_convertt::convert_cpp_delete(
typet arg_type=
to_code_type(delete_symbol.type()).parameters().front().type();

code_function_callt delete_call;
delete_call.function()=delete_symbol;
delete_call.arguments().push_back(typecast_exprt(tmp_op, arg_type));
code_function_callt delete_call(
nil_exprt(), delete_symbol, {typecast_exprt(tmp_op, arg_type)});
delete_call.lhs().make_nil();
delete_call.add_source_location()=code.source_location();

Expand Down
5 changes: 1 addition & 4 deletions src/goto-programs/goto_convert_function_call.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,8 @@ void goto_convertt::do_function_call_other(
// don't know what to do with it
goto_programt::targett t=dest.add_instruction(FUNCTION_CALL);

code_function_callt function_call;
code_function_callt function_call(lhs, function, arguments);
function_call.add_source_location()=function.source_location();
function_call.lhs()=lhs;
function_call.function()=function;
function_call.arguments()=arguments;

t->source_location=function.source_location();
t->code.swap(function_call);
Expand Down
11 changes: 3 additions & 8 deletions src/goto-programs/goto_convert_side_effect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,8 @@ void goto_convertt::remove_function_call(
if(!result_is_used)
{
assert(expr.operands().size()==2);
code_function_callt call;
call.function()=expr.op0();
call.arguments()=expr.op1().operands();
code_function_callt call(nil_exprt(), expr.op0(), expr.op1().operands());
call.add_source_location()=expr.source_location();
call.lhs().make_nil();
convert_function_call(call, dest, mode);
expr.make_nil();
return;
Expand Down Expand Up @@ -397,10 +394,8 @@ void goto_convertt::remove_function_call(

{
goto_programt tmp_program2;
code_function_callt call;
call.lhs()=new_symbol.symbol_expr();
call.function()=expr.op0();
call.arguments()=expr.op1().operands();
code_function_callt call(
new_symbol.symbol_expr(), expr.op0(), expr.op1().operands());
call.add_source_location()=new_symbol.location;
convert_function_call(call, dest, mode);
}
Expand Down
6 changes: 2 additions & 4 deletions src/goto-programs/mm_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ void mm_io(
const dereference_exprt &d=*deref_expr_r.begin();
source_locationt source_location=it->source_location;
irep_idt function=it->function;
code_function_callt fc;
const code_typet &ct=to_code_type(mm_io_r.type());

irep_idt identifier=to_symbol_expr(mm_io_r).get_identifier();
Expand All @@ -67,10 +66,10 @@ void mm_io(
const typet &pt=ct.parameters()[0].type();
const typet &st=ct.parameters()[1].type();
exprt size=size_of_expr(d.type(), ns);
code_function_callt fc(mm_io_r);
fc.arguments().resize(2);
fc.arguments()[0]=typecast_exprt(d.pointer(), pt);
fc.arguments()[1]=typecast_exprt(size, st);
fc.function()=mm_io_r;
goto_function.body.insert_before_swap(it);
it->make_function_call(fc);
it->source_location=source_location;
Expand All @@ -86,17 +85,16 @@ void mm_io(
const dereference_exprt &d=to_dereference_expr(a.lhs());
source_locationt source_location=it->source_location;
irep_idt function=it->function;
code_function_callt fc;
const code_typet &ct=to_code_type(mm_io_w.type());
const typet &pt=ct.parameters()[0].type();
const typet &st=ct.parameters()[1].type();
const typet &vt=ct.parameters()[2].type();
exprt size=size_of_expr(d.type(), ns);
code_function_callt fc(mm_io_w);
fc.arguments().resize(3);
fc.arguments()[0]=typecast_exprt(d.pointer(), pt);
fc.arguments()[1]=typecast_exprt(size, st);
fc.arguments()[2]=typecast_exprt(a.rhs(), vt);
fc.function()=mm_io_w;
goto_function.body.insert_before_swap(it);
it->make_function_call(fc);
it->source_location=source_location;
Expand Down
5 changes: 1 addition & 4 deletions src/jsil/jsil_convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@ bool jsil_convertt::convert_code(const symbolt &symbol, codet &code)
side_effect_expr_function_callt f_expr=
to_side_effect_expr_function_call(a.rhs());

code_function_callt f;
f.lhs().swap(a.lhs());
f.function().swap(f_expr.function());
f.arguments().swap(f_expr.arguments());
code_function_callt f(a.lhs(), f_expr.function(), f_expr.arguments());
f.add_source_location()=code.source_location();

code.swap(f);
Expand Down
8 changes: 2 additions & 6 deletions src/jsil/jsil_entry_point.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,15 @@ bool jsil_entry_point(
if(init_it==symbol_table.symbols.end())
throw "failed to find " INITIALIZE_FUNCTION " symbol";

code_function_callt call_init;
call_init.lhs().make_nil();
code_function_callt call_init(init_it->second.symbol_expr());
call_init.add_source_location()=symbol.location;
call_init.function()=init_it->second.symbol_expr();

init_code.move_to_operands(call_init);
}

// build call to main function

code_function_callt call_main;
code_function_callt call_main(symbol.symbol_expr());
call_main.add_source_location()=symbol.location;
call_main.function()=symbol.symbol_expr();
call_main.function().add_source_location()=symbol.location;

init_code.move_to_operands(call_main);
Expand Down
3 changes: 1 addition & 2 deletions src/linking/static_lifetime_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,7 @@ bool static_lifetime_init(
code_type.return_type().id() == ID_constructor &&
code_type.parameters().empty())
{
code_function_callt function_call;
function_call.function()=symbol.symbol_expr();
code_function_callt function_call(symbol.symbol_expr());
function_call.add_source_location()=source_location;
dest.move_to_operands(function_call);
}
Expand Down
33 changes: 31 additions & 2 deletions src/util/std_code.h
Original file line number Diff line number Diff line change
Expand Up @@ -865,13 +865,44 @@ inline code_gotot &to_code_goto(codet &code)
class code_function_callt:public codet
{
public:
DEPRECATED("Use code_function_callt(...) instead")
code_function_callt():codet(ID_function_call)
{
operands().resize(3);
lhs().make_nil();
op2().id(ID_arguments);
}

explicit code_function_callt(const exprt &_function) : codet(ID_function_call)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mark the no-argument constructor as deprecated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

{
operands().resize(3);
lhs().make_nil();
op2().id(ID_arguments);
function() = _function;
}

typedef exprt::operandst argumentst;

code_function_callt(
const exprt &_lhs,
const exprt &_function,
argumentst &&_arguments)
: code_function_callt(_function)
{
lhs() = _lhs;
arguments() = std::move(_arguments);
}

code_function_callt(
const exprt &_lhs,
const exprt &_function,
const argumentst &_arguments)
: code_function_callt(_function)
{
lhs() = _lhs;
arguments() = _arguments;
}

exprt &lhs()
{
return op0();
Expand All @@ -892,8 +923,6 @@ class code_function_callt:public codet
return op1();
}

typedef exprt::operandst argumentst;

argumentst &arguments()
{
return op2().operands();
Expand Down