Skip to content

Commit c59500b

Browse files
authored
Merge pull request #3907 from tautschnig/deprecation-side_eff_function_call
Construct side_effect_expr_function_callt in a non-deprecated way [blocks: #3800]
2 parents 6c3abfa + 28ea7a5 commit c59500b

File tree

8 files changed

+87
-86
lines changed

8 files changed

+87
-86
lines changed

src/cpp/cpp_constructor.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ optionalt<codet> cpp_typecheckt::cpp_constructor(
223223

224224
side_effect_expr_function_callt function_call(
225225
cpp_namet(constructor_name, source_location).as_expr(),
226-
operands_tc);
227-
228-
function_call.add_source_location()=source_location;
226+
operands_tc,
227+
uninitialized_typet(),
228+
source_location);
229229

230230
typecheck_side_effect_function_call(function_call);
231231
assert(function_call.get(ID_statement)==ID_temporary_object);

src/cpp/cpp_destructor.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,8 @@ optionalt<codet> cpp_typecheckt::cpp_destructor(
106106
member.add(ID_component_cpp_name) = cpp_name;
107107
member.copy_to_operands(object);
108108

109-
side_effect_expr_function_callt function_call;
110-
function_call.add_source_location()=source_location;
111-
function_call.function().swap(member);
109+
side_effect_expr_function_callt function_call(
110+
std::move(member), {}, uninitialized_typet{}, source_location);
112111

113112
typecheck_side_effect_function_call(function_call);
114113
already_typechecked(function_call);

src/cpp/cpp_typecheck_code.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,8 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code)
203203
assert(code_type.parameters().size()>=1);
204204

205205
// It's a parent. Call the constructor that we got.
206-
side_effect_expr_function_callt function_call;
207-
208-
function_call.function()=symbol_expr;
209-
function_call.add_source_location()=code.source_location();
206+
side_effect_expr_function_callt function_call(
207+
symbol_expr, {}, uninitialized_typet{}, code.source_location());
210208
function_call.arguments().reserve(code.operands().size()+1);
211209

212210
// we have to add 'this'

src/cpp/cpp_typecheck_compound_type.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -651,11 +651,12 @@ void cpp_typecheckt::typecheck_compound_declarator(
651651
lookup(args[0].get(ID_C_identifier)).symbol_expr(),
652652
to_code_type(component.type()).parameters()[0].type());
653653

654-
side_effect_expr_function_callt expr_call;
655-
expr_call.function() =
656-
symbol_exprt(component.get_name(), component.type());
654+
side_effect_expr_function_callt expr_call(
655+
symbol_exprt(component.get_name(), component.type()),
656+
{late_cast},
657+
uninitialized_typet{},
658+
source_locationt{});
657659
expr_call.arguments().reserve(args.size());
658-
expr_call.arguments().push_back(late_cast);
659660

660661
for(const auto &arg : args)
661662
{

src/cpp/cpp_typecheck_conversions.cpp

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -991,10 +991,11 @@ bool cpp_typecheckt::user_defined_conversion_sequence(
991991
}
992992

993993
// create temporary object
994-
side_effect_expr_function_callt ctor_expr;
995-
ctor_expr.add_source_location()=expr.source_location();
996-
ctor_expr.function().swap(func_symb);
997-
ctor_expr.arguments().push_back(tmp_expr);
994+
side_effect_expr_function_callt ctor_expr(
995+
std::move(func_symb),
996+
{tmp_expr},
997+
uninitialized_typet{},
998+
expr.source_location());
998999
typecheck_side_effect_function_call(ctor_expr);
9991000

10001001
new_expr.swap(ctor_expr);
@@ -1041,10 +1042,11 @@ bool cpp_typecheckt::user_defined_conversion_sequence(
10411042
func_symb.swap(func_symb);
10421043
}
10431044

1044-
side_effect_expr_function_callt ctor_expr;
1045-
ctor_expr.add_source_location()=expr.source_location();
1046-
ctor_expr.function().swap(func_symb);
1047-
ctor_expr.arguments().push_back(expr_deref);
1045+
side_effect_expr_function_callt ctor_expr(
1046+
std::move(func_symb),
1047+
{expr_deref},
1048+
uninitialized_typet{},
1049+
expr.source_location());
10481050
typecheck_side_effect_function_call(ctor_expr);
10491051

10501052
new_expr.swap(ctor_expr);
@@ -1101,9 +1103,11 @@ bool cpp_typecheckt::user_defined_conversion_sequence(
11011103
ac.copy_to_operands(expr);
11021104
member_func.copy_to_operands(ac);
11031105

1104-
side_effect_expr_function_callt func_expr;
1105-
func_expr.add_source_location()=expr.source_location();
1106-
func_expr.function().swap(member_func);
1106+
side_effect_expr_function_callt func_expr(
1107+
std::move(member_func),
1108+
{},
1109+
uninitialized_typet{},
1110+
expr.source_location());
11071111
typecheck_side_effect_function_call(func_expr);
11081112

11091113
if(standard_conversion_sequence(func_expr, type, tmp_expr, tmp_rank))
@@ -1328,9 +1332,11 @@ bool cpp_typecheckt::reference_binding(
13281332
ac.copy_to_operands(expr);
13291333
member_func.copy_to_operands(ac);
13301334

1331-
side_effect_expr_function_callt func_expr;
1332-
func_expr.add_source_location()=expr.source_location();
1333-
func_expr.function().swap(member_func);
1335+
side_effect_expr_function_callt func_expr(
1336+
std::move(member_func),
1337+
{},
1338+
uninitialized_typet{},
1339+
expr.source_location());
13341340
typecheck_side_effect_function_call(func_expr);
13351341

13361342
// let's check if the returned value binds directly

src/cpp/cpp_typecheck_expr.cpp

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -381,17 +381,16 @@ void cpp_typecheckt::typecheck_function_expr(
381381
std::string op_name="operator->";
382382

383383
// turn this into a function call
384-
side_effect_expr_function_callt function_call;
385-
function_call.arguments().reserve(expr.operands().size());
386-
function_call.add_source_location()=expr.source_location();
387-
388384
// first do function/operator
389385
const cpp_namet cpp_name(op_name, expr.source_location());
390386

391-
function_call.function() = cpp_name.as_expr();
387+
side_effect_expr_function_callt function_call(
388+
cpp_name.as_expr(),
389+
{expr.op0()},
390+
uninitialized_typet{},
391+
expr.source_location());
392+
function_call.arguments().reserve(expr.operands().size());
392393

393-
// now do the argument
394-
function_call.arguments().push_back(expr.op0());
395394
typecheck_side_effect_function_call(function_call);
396395

397396
exprt tmp(ID_already_typechecked);
@@ -487,10 +486,6 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr)
487486
std::string op_name=std::string("operator")+"("+cpp_type2name(t)+")";
488487

489488
// turn this into a function call
490-
side_effect_expr_function_callt function_call;
491-
function_call.arguments().reserve(expr.operands().size());
492-
function_call.add_source_location()=expr.source_location();
493-
494489
const cpp_namet cpp_name(op_name, expr.source_location());
495490

496491
// See if the struct declares the cast operator as a member
@@ -513,16 +508,16 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr)
513508
if(!found_in_struct)
514509
return false;
515510

516-
{
517-
exprt member(ID_member);
518-
member.add(ID_component_cpp_name)= cpp_name;
511+
exprt member(ID_member);
512+
member.add(ID_component_cpp_name) = cpp_name;
519513

520-
exprt tmp(ID_already_typechecked);
521-
tmp.copy_to_operands(expr.op0());
522-
member.copy_to_operands(tmp);
514+
exprt tmp(ID_already_typechecked);
515+
tmp.copy_to_operands(expr.op0());
516+
member.copy_to_operands(tmp);
523517

524-
function_call.function()=member;
525-
}
518+
side_effect_expr_function_callt function_call(
519+
std::move(member), {}, uninitialized_typet{}, expr.source_location());
520+
function_call.arguments().reserve(expr.operands().size());
526521

527522
if(expr.operands().size()>1)
528523
{
@@ -563,10 +558,6 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr)
563558
const cpp_namet cpp_name(op_name, expr.source_location());
564559

565560
// turn this into a function call
566-
side_effect_expr_function_callt function_call;
567-
function_call.arguments().reserve(expr.operands().size());
568-
function_call.add_source_location()=expr.source_location();
569-
570561
// There are two options to overload an operator:
571562
//
572563
// 1. In the scope of a as a.operator(b, ...)
@@ -603,16 +594,19 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr)
603594
if(resolve_result.is_not_nil())
604595
{
605596
// Found! We turn op(a, b, ...) into a.op(b, ...)
606-
{
607-
exprt member(ID_member);
608-
member.add(ID_component_cpp_name)=cpp_name;
597+
exprt member(ID_member);
598+
member.add(ID_component_cpp_name) = cpp_name;
609599

610-
exprt tmp(ID_already_typechecked);
611-
tmp.copy_to_operands(expr.op0());
612-
member.copy_to_operands(tmp);
600+
exprt tmp(ID_already_typechecked);
601+
tmp.copy_to_operands(expr.op0());
602+
member.copy_to_operands(tmp);
613603

614-
function_call.function()=member;
615-
}
604+
side_effect_expr_function_callt function_call(
605+
std::move(member),
606+
{},
607+
uninitialized_typet{},
608+
expr.source_location());
609+
function_call.arguments().reserve(expr.operands().size());
616610

617611
if(expr.operands().size()>1)
618612
{
@@ -645,9 +639,12 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr)
645639
if(resolve_result.is_not_nil())
646640
{
647641
// found!
648-
function_call.function()=
649-
static_cast<const exprt &>(
650-
static_cast<const irept &>(cpp_name));
642+
side_effect_expr_function_callt function_call(
643+
cpp_name.as_expr(),
644+
{},
645+
uninitialized_typet{},
646+
expr.source_location());
647+
function_call.arguments().reserve(expr.operands().size());
651648

652649
// now do arguments
653650
forall_operands(it, expr)
@@ -904,11 +901,11 @@ void cpp_typecheckt::typecheck_expr_explicit_typecast(exprt &expr)
904901
{
905902
// It's really a function call. Note that multiple arguments
906903
// become a comma expression, and that these are already typechecked.
907-
side_effect_expr_function_callt f_call;
908-
909-
f_call.add_source_location()=expr.source_location();
910-
f_call.function().swap(expr.type());
911-
f_call.arguments()=collect_comma_expression(expr.op0()).operands();
904+
side_effect_expr_function_callt f_call(
905+
static_cast<const exprt &>(static_cast<const irept &>(expr.type())),
906+
collect_comma_expression(expr.op0()).operands(),
907+
uninitialized_typet{},
908+
expr.source_location());
912909

913910
typecheck_side_effect_function_call(f_call);
914911

@@ -2495,10 +2492,11 @@ void cpp_typecheckt::typecheck_side_effect_assignment(side_effect_exprt &expr)
24952492
member.set(ID_component_cpp_name, cpp_name);
24962493
member.add_to_operands(std::move(already_typechecked));
24972494

2498-
side_effect_expr_function_callt new_expr;
2499-
new_expr.function().swap(member);
2500-
new_expr.arguments().push_back(expr.op1());
2501-
new_expr.add_source_location()=expr.source_location();
2495+
side_effect_expr_function_callt new_expr(
2496+
std::move(member),
2497+
{expr.op1()},
2498+
uninitialized_typet{},
2499+
expr.source_location());
25022500

25032501
typecheck_side_effect_function_call(new_expr);
25042502

@@ -2565,9 +2563,8 @@ void cpp_typecheckt::typecheck_side_effect_inc_dec(
25652563
member.set(ID_component_cpp_name, cpp_name);
25662564
member.add_to_operands(std::move(already_typechecked));
25672565

2568-
side_effect_expr_function_callt new_expr;
2569-
new_expr.function().swap(member);
2570-
new_expr.add_source_location()=expr.source_location();
2566+
side_effect_expr_function_callt new_expr(
2567+
std::move(member), {}, uninitialized_typet{}, expr.source_location());
25712568

25722569
// the odd C++ way to denote the post-inc/dec operator
25732570
if(post)

src/goto-instrument/goto_program2code.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,13 @@ goto_programt::const_targett goto_program2codet::convert_assign_varargs(
342342
{this_va_list_expr});
343343
f.arguments().back().type().id(ID_gcc_builtin_va_list);
344344

345-
side_effect_expr_function_callt type_of;
346-
type_of.function() =
347-
symbol_exprt("__typeof__", code_typet({}, empty_typet()));
345+
// we do not bother to set the correct types here, they are not relevant for
346+
// generating the correct dumped output
347+
side_effect_expr_function_callt type_of(
348+
symbol_exprt("__typeof__", code_typet({}, empty_typet())),
349+
{},
350+
typet{},
351+
source_locationt{});
348352

349353
// if the return value is used, the next instruction will be assign
350354
goto_programt::const_targett next=target;
@@ -486,9 +490,8 @@ goto_programt::const_targett goto_program2codet::convert_decl(
486490
{
487491
// could hack this by just erasing the first operand
488492
const code_function_callt &f=to_code_function_call(next->code);
489-
side_effect_expr_function_callt call;
490-
call.function()=f.function();
491-
call.arguments()=f.arguments();
493+
side_effect_expr_function_callt call(
494+
f.function(), f.arguments(), typet{}, source_locationt{});
492495
d.copy_to_operands(call);
493496
}
494497

@@ -1919,10 +1922,8 @@ void goto_program2codet::cleanup_expr(exprt &expr, bool no_typecast)
19191922
symbol_exprt symbol_expr(symbol.name, symbol.type);
19201923
symbol_expr.add_source_location()=expr.source_location();
19211924

1922-
side_effect_expr_function_callt call;
1923-
call.add_source_location()=expr.source_location();
1924-
call.function()=symbol_expr;
1925-
call.type()=expr.type();
1925+
side_effect_expr_function_callt call(
1926+
symbol_expr, {}, expr.type(), expr.source_location());
19261927

19271928
expr.swap(call);
19281929
}

src/jsil/parser.y

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,7 @@ instruction: TOK_LABEL TOK_IDENTIFIER
260260
rhs: expression
261261
| proc_ident_expr '(' expressions_opt ')' with_opt
262262
{
263-
side_effect_expr_function_callt f;
264-
f.function().swap(stack($1));
263+
side_effect_expr_function_callt f(stack($1), {}, typet{}, {});
265264
if(stack($3).is_not_nil())
266265
f.arguments().swap(stack($3).operands());
267266

0 commit comments

Comments
 (0)