Skip to content

Commit cdd94b9

Browse files
author
Daniel Kroening
authored
Merge pull request #2841 from diffblue/code_function_callt_constructors
added three constructors to code_function_callt
2 parents 141503e + 7c6ea9f commit cdd94b9

15 files changed

+63
-80
lines changed

src/analyses/escape_analysis.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,9 +406,7 @@ void escape_analysist::insert_cleanup(
406406
const code_typet &function_type=to_code_type(function.type());
407407

408408
goto_function.body.insert_before_swap(location);
409-
code_function_callt code;
410-
code.lhs().make_nil();
411-
code.function()=function;
409+
code_function_callt code(function);
412410
code.function().add_source_location()=source_location;
413411

414412
if(function_type.parameters().size()==1)

src/ansi-c/ansi_c_entry_point.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,19 +213,16 @@ bool generate_ansi_c_start_function(
213213
return true;
214214
}
215215

216-
code_function_callt call_init;
217-
call_init.lhs().make_nil();
216+
code_function_callt call_init(init_it->second.symbol_expr());
218217
call_init.add_source_location()=symbol.location;
219-
call_init.function()=init_it->second.symbol_expr();
220218

221219
init_code.move_to_operands(call_init);
222220
}
223221

224222
// build call to main function
225223

226-
code_function_callt call_main;
224+
code_function_callt call_main(symbol.symbol_expr());
227225
call_main.add_source_location()=symbol.location;
228-
call_main.function()=symbol.symbol_expr();
229226
call_main.function().add_source_location()=symbol.location;
230227

231228
if(to_code_type(symbol.type).return_type()!=empty_typet())

src/goto-instrument/code_contracts.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,7 @@ void code_contractst::add_contract_check(
301301
g->source_location=skip->source_location;
302302

303303
// prepare function call including all declarations
304-
code_function_callt call;
305-
call.function()=ns.lookup(function).symbol_expr();
304+
code_function_callt call(ns.lookup(function).symbol_expr());
306305
replace_symbolt replace;
307306

308307
// decl ret

src/goto-instrument/function.cpp

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,13 @@ code_function_callt function_to_call(
5959

6060
string_constantt function_id_string(argument);
6161

62-
code_function_callt call;
63-
call.lhs().make_nil();
64-
call.function()=
65-
symbol_exprt(s_it->second.name, s_it->second.type);
66-
call.arguments().resize(1);
67-
call.arguments()[0]=
68-
typecast_exprt(
62+
code_function_callt call(
63+
nil_exprt(),
64+
symbol_exprt(s_it->second.name, s_it->second.type),
65+
{typecast_exprt(
6966
address_of_exprt(
70-
index_exprt(
71-
function_id_string, from_integer(0, index_type()))),
72-
to_code_type(s_it->second.type).parameters()[0].type());
67+
index_exprt(function_id_string, from_integer(0, index_type()))),
68+
to_code_type(s_it->second.type).parameters()[0].type())});
7369

7470
return call;
7571
}

src/goto-instrument/goto_program2code.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,11 @@ goto_programt::const_targett goto_program2codet::convert_instruction(
220220
case ATOMIC_BEGIN:
221221
case ATOMIC_END:
222222
{
223-
code_function_callt f;
224223
const code_typet void_t({}, empty_typet());
225-
f.function()=symbol_exprt(
226-
target->is_atomic_begin() ?
227-
"__CPROVER_atomic_begin" :
228-
"__CPROVER_atomic_end",
229-
void_t);
224+
code_function_callt f(symbol_exprt(
225+
target->is_atomic_begin() ? "__CPROVER_atomic_begin"
226+
: "__CPROVER_atomic_end",
227+
void_t));
230228
dest.move_to_operands(f);
231229
return target;
232230
}

src/goto-programs/builtin_functions.cpp

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,7 @@ void goto_convertt::do_scanf(
309309
else
310310
{
311311
// we'll just do nothing
312-
code_function_callt function_call;
313-
function_call.lhs()=lhs;
314-
function_call.function()=function;
315-
function_call.arguments()=arguments;
312+
code_function_callt function_call(lhs, function, arguments);
316313
function_call.add_source_location()=function.source_location();
317314

318315
copy(function_call, FUNCTION_CALL, dest);
@@ -462,8 +459,7 @@ void goto_convertt::do_cpp_new(
462459

463460
tmp_symbol_expr=tmp_symbol.symbol_expr();
464461

465-
code_function_callt new_call;
466-
new_call.function()=new_symbol;
462+
code_function_callt new_call(new_symbol);
467463
if(new_array)
468464
new_call.arguments().push_back(count);
469465
new_call.arguments().push_back(object_size);
@@ -493,8 +489,7 @@ void goto_convertt::do_cpp_new(
493489

494490
tmp_symbol_expr=tmp_symbol.symbol_expr();
495491

496-
code_function_callt new_call;
497-
new_call.function()=new_symbol;
492+
code_function_callt new_call(new_symbol);
498493
if(new_array)
499494
new_call.arguments().push_back(count);
500495
new_call.arguments().push_back(object_size);
@@ -1552,10 +1547,7 @@ void goto_convertt::do_function_call_symbol(
15521547
new_function.set_identifier(name);
15531548
new_function.type()=f_type;
15541549

1555-
code_function_callt function_call;
1556-
function_call.lhs()=lhs;
1557-
function_call.function()=new_function;
1558-
function_call.arguments()=new_arguments;
1550+
code_function_callt function_call(lhs, new_function, new_arguments);
15591551
function_call.add_source_location()=function.source_location();
15601552

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

15771569
// insert function call
1578-
code_function_callt function_call;
1579-
function_call.lhs()=lhs;
1580-
function_call.function()=function;
1581-
function_call.arguments()=arguments;
1570+
code_function_callt function_call(lhs, function, arguments);
15821571
function_call.add_source_location()=function.source_location();
15831572

15841573
copy(function_call, FUNCTION_CALL, dest);

src/goto-programs/destructor.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,7 @@ code_function_callt get_destructor(
4242
ns.follow(arg_type.subtype())==type)
4343
{
4444
const symbol_exprt symbol_expr(it->get(ID_name), it->type());
45-
46-
code_function_callt function_call;
47-
function_call.function()=symbol_expr;
48-
49-
return function_call;
45+
return code_function_callt(symbol_expr);
5046
}
5147
}
5248
}

src/goto-programs/goto_convert.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -897,9 +897,8 @@ void goto_convertt::convert_cpp_delete(
897897
typet arg_type=
898898
to_code_type(delete_symbol.type()).parameters().front().type();
899899

900-
code_function_callt delete_call;
901-
delete_call.function()=delete_symbol;
902-
delete_call.arguments().push_back(typecast_exprt(tmp_op, arg_type));
900+
code_function_callt delete_call(
901+
nil_exprt(), delete_symbol, {typecast_exprt(tmp_op, arg_type)});
903902
delete_call.lhs().make_nil();
904903
delete_call.add_source_location()=code.source_location();
905904

src/goto-programs/goto_convert_function_call.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,8 @@ void goto_convertt::do_function_call_other(
166166
// don't know what to do with it
167167
goto_programt::targett t=dest.add_instruction(FUNCTION_CALL);
168168

169-
code_function_callt function_call;
169+
code_function_callt function_call(lhs, function, arguments);
170170
function_call.add_source_location()=function.source_location();
171-
function_call.lhs()=lhs;
172-
function_call.function()=function;
173-
function_call.arguments()=arguments;
174171

175172
t->source_location=function.source_location();
176173
t->code.swap(function_call);

src/goto-programs/goto_convert_side_effect.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -341,11 +341,8 @@ void goto_convertt::remove_function_call(
341341
if(!result_is_used)
342342
{
343343
assert(expr.operands().size()==2);
344-
code_function_callt call;
345-
call.function()=expr.op0();
346-
call.arguments()=expr.op1().operands();
344+
code_function_callt call(nil_exprt(), expr.op0(), expr.op1().operands());
347345
call.add_source_location()=expr.source_location();
348-
call.lhs().make_nil();
349346
convert_function_call(call, dest, mode);
350347
expr.make_nil();
351348
return;
@@ -397,10 +394,8 @@ void goto_convertt::remove_function_call(
397394

398395
{
399396
goto_programt tmp_program2;
400-
code_function_callt call;
401-
call.lhs()=new_symbol.symbol_expr();
402-
call.function()=expr.op0();
403-
call.arguments()=expr.op1().operands();
397+
code_function_callt call(
398+
new_symbol.symbol_expr(), expr.op0(), expr.op1().operands());
404399
call.add_source_location()=new_symbol.location;
405400
convert_function_call(call, dest, mode);
406401
}

0 commit comments

Comments
 (0)