Skip to content

Construct side_effect_expr_function_callt in a non-deprecated way [blocks: #3800] #3907

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
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
6 changes: 3 additions & 3 deletions src/cpp/cpp_constructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ optionalt<codet> cpp_typecheckt::cpp_constructor(

side_effect_expr_function_callt function_call(
cpp_namet(constructor_name, source_location).as_expr(),
operands_tc);

function_call.add_source_location()=source_location;
operands_tc,
uninitialized_typet(),
source_location);

typecheck_side_effect_function_call(function_call);
assert(function_call.get(ID_statement)==ID_temporary_object);
Expand Down
5 changes: 2 additions & 3 deletions src/cpp/cpp_destructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,8 @@ optionalt<codet> cpp_typecheckt::cpp_destructor(
member.add(ID_component_cpp_name) = cpp_name;
member.copy_to_operands(object);

side_effect_expr_function_callt function_call;
function_call.add_source_location()=source_location;
function_call.function().swap(member);
side_effect_expr_function_callt function_call(
std::move(member), {}, uninitialized_typet{}, source_location);

typecheck_side_effect_function_call(function_call);
already_typechecked(function_call);
Expand Down
6 changes: 2 additions & 4 deletions src/cpp/cpp_typecheck_code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,10 +203,8 @@ void cpp_typecheckt::typecheck_member_initializer(codet &code)
assert(code_type.parameters().size()>=1);

// It's a parent. Call the constructor that we got.
side_effect_expr_function_callt function_call;

function_call.function()=symbol_expr;
function_call.add_source_location()=code.source_location();
side_effect_expr_function_callt function_call(
symbol_expr, {}, uninitialized_typet{}, code.source_location());
function_call.arguments().reserve(code.operands().size()+1);

// we have to add 'this'
Expand Down
9 changes: 5 additions & 4 deletions src/cpp/cpp_typecheck_compound_type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,11 +651,12 @@ void cpp_typecheckt::typecheck_compound_declarator(
lookup(args[0].get(ID_C_identifier)).symbol_expr(),
to_code_type(component.type()).parameters()[0].type());

side_effect_expr_function_callt expr_call;
expr_call.function() =
symbol_exprt(component.get_name(), component.type());
side_effect_expr_function_callt expr_call(
symbol_exprt(component.get_name(), component.type()),
{late_cast},
uninitialized_typet{},
source_locationt{});
expr_call.arguments().reserve(args.size());
expr_call.arguments().push_back(late_cast);

for(const auto &arg : args)
{
Expand Down
34 changes: 20 additions & 14 deletions src/cpp/cpp_typecheck_conversions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -991,10 +991,11 @@ bool cpp_typecheckt::user_defined_conversion_sequence(
}

// create temporary object
side_effect_expr_function_callt ctor_expr;
ctor_expr.add_source_location()=expr.source_location();
ctor_expr.function().swap(func_symb);
ctor_expr.arguments().push_back(tmp_expr);
side_effect_expr_function_callt ctor_expr(
std::move(func_symb),
{tmp_expr},
uninitialized_typet{},
expr.source_location());
typecheck_side_effect_function_call(ctor_expr);

new_expr.swap(ctor_expr);
Expand Down Expand Up @@ -1041,10 +1042,11 @@ bool cpp_typecheckt::user_defined_conversion_sequence(
func_symb.swap(func_symb);
}

side_effect_expr_function_callt ctor_expr;
ctor_expr.add_source_location()=expr.source_location();
ctor_expr.function().swap(func_symb);
ctor_expr.arguments().push_back(expr_deref);
side_effect_expr_function_callt ctor_expr(
std::move(func_symb),
{expr_deref},
uninitialized_typet{},
expr.source_location());
typecheck_side_effect_function_call(ctor_expr);

new_expr.swap(ctor_expr);
Expand Down Expand Up @@ -1101,9 +1103,11 @@ bool cpp_typecheckt::user_defined_conversion_sequence(
ac.copy_to_operands(expr);
member_func.copy_to_operands(ac);

side_effect_expr_function_callt func_expr;
func_expr.add_source_location()=expr.source_location();
func_expr.function().swap(member_func);
side_effect_expr_function_callt func_expr(
std::move(member_func),
{},
uninitialized_typet{},
expr.source_location());
typecheck_side_effect_function_call(func_expr);

if(standard_conversion_sequence(func_expr, type, tmp_expr, tmp_rank))
Expand Down Expand Up @@ -1328,9 +1332,11 @@ bool cpp_typecheckt::reference_binding(
ac.copy_to_operands(expr);
member_func.copy_to_operands(ac);

side_effect_expr_function_callt func_expr;
func_expr.add_source_location()=expr.source_location();
func_expr.function().swap(member_func);
side_effect_expr_function_callt func_expr(
std::move(member_func),
{},
uninitialized_typet{},
expr.source_location());
typecheck_side_effect_function_call(func_expr);

// let's check if the returned value binds directly
Expand Down
89 changes: 43 additions & 46 deletions src/cpp/cpp_typecheck_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,17 +381,16 @@ void cpp_typecheckt::typecheck_function_expr(
std::string op_name="operator->";

// turn this into a function call
side_effect_expr_function_callt function_call;
function_call.arguments().reserve(expr.operands().size());
function_call.add_source_location()=expr.source_location();

// first do function/operator
const cpp_namet cpp_name(op_name, expr.source_location());

function_call.function() = cpp_name.as_expr();
side_effect_expr_function_callt function_call(
cpp_name.as_expr(),
{expr.op0()},
uninitialized_typet{},
expr.source_location());
function_call.arguments().reserve(expr.operands().size());

// now do the argument
function_call.arguments().push_back(expr.op0());
typecheck_side_effect_function_call(function_call);

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

// turn this into a function call
side_effect_expr_function_callt function_call;
function_call.arguments().reserve(expr.operands().size());
function_call.add_source_location()=expr.source_location();

const cpp_namet cpp_name(op_name, expr.source_location());

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

{
exprt member(ID_member);
member.add(ID_component_cpp_name)= cpp_name;
exprt member(ID_member);
member.add(ID_component_cpp_name) = cpp_name;

exprt tmp(ID_already_typechecked);
tmp.copy_to_operands(expr.op0());
member.copy_to_operands(tmp);
exprt tmp(ID_already_typechecked);
tmp.copy_to_operands(expr.op0());
member.copy_to_operands(tmp);

function_call.function()=member;
}
side_effect_expr_function_callt function_call(
std::move(member), {}, uninitialized_typet{}, expr.source_location());
function_call.arguments().reserve(expr.operands().size());

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

// turn this into a function call
side_effect_expr_function_callt function_call;
function_call.arguments().reserve(expr.operands().size());
function_call.add_source_location()=expr.source_location();

// There are two options to overload an operator:
//
// 1. In the scope of a as a.operator(b, ...)
Expand Down Expand Up @@ -603,16 +594,19 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr)
if(resolve_result.is_not_nil())
{
// Found! We turn op(a, b, ...) into a.op(b, ...)
{
exprt member(ID_member);
member.add(ID_component_cpp_name)=cpp_name;
exprt member(ID_member);
member.add(ID_component_cpp_name) = cpp_name;

exprt tmp(ID_already_typechecked);
tmp.copy_to_operands(expr.op0());
member.copy_to_operands(tmp);
exprt tmp(ID_already_typechecked);
tmp.copy_to_operands(expr.op0());
member.copy_to_operands(tmp);

function_call.function()=member;
}
side_effect_expr_function_callt function_call(
std::move(member),
{},
uninitialized_typet{},
expr.source_location());
function_call.arguments().reserve(expr.operands().size());

if(expr.operands().size()>1)
{
Expand Down Expand Up @@ -645,9 +639,12 @@ bool cpp_typecheckt::operator_is_overloaded(exprt &expr)
if(resolve_result.is_not_nil())
{
// found!
function_call.function()=
static_cast<const exprt &>(
static_cast<const irept &>(cpp_name));
side_effect_expr_function_callt function_call(
cpp_name.as_expr(),
{},
uninitialized_typet{},
expr.source_location());
function_call.arguments().reserve(expr.operands().size());

// now do arguments
forall_operands(it, expr)
Expand Down Expand Up @@ -904,11 +901,11 @@ void cpp_typecheckt::typecheck_expr_explicit_typecast(exprt &expr)
{
// It's really a function call. Note that multiple arguments
// become a comma expression, and that these are already typechecked.
side_effect_expr_function_callt f_call;

f_call.add_source_location()=expr.source_location();
f_call.function().swap(expr.type());
f_call.arguments()=collect_comma_expression(expr.op0()).operands();
side_effect_expr_function_callt f_call(
static_cast<const exprt &>(static_cast<const irept &>(expr.type())),
collect_comma_expression(expr.op0()).operands(),
uninitialized_typet{},
expr.source_location());

typecheck_side_effect_function_call(f_call);

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

side_effect_expr_function_callt new_expr;
new_expr.function().swap(member);
new_expr.arguments().push_back(expr.op1());
new_expr.add_source_location()=expr.source_location();
side_effect_expr_function_callt new_expr(
std::move(member),
{expr.op1()},
uninitialized_typet{},
expr.source_location());

typecheck_side_effect_function_call(new_expr);

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

side_effect_expr_function_callt new_expr;
new_expr.function().swap(member);
new_expr.add_source_location()=expr.source_location();
side_effect_expr_function_callt new_expr(
std::move(member), {}, uninitialized_typet{}, expr.source_location());

// the odd C++ way to denote the post-inc/dec operator
if(post)
Expand Down
21 changes: 11 additions & 10 deletions src/goto-instrument/goto_program2code.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,13 @@ goto_programt::const_targett goto_program2codet::convert_assign_varargs(
{this_va_list_expr});
f.arguments().back().type().id(ID_gcc_builtin_va_list);

side_effect_expr_function_callt type_of;
type_of.function() =
symbol_exprt("__typeof__", code_typet({}, empty_typet()));
// we do not bother to set the correct types here, they are not relevant for
// generating the correct dumped output
side_effect_expr_function_callt type_of(
Copy link
Contributor

Choose a reason for hiding this comment

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

How do we eventually get away with this apparently-wrong type? Comment here to say where the fixup takes place?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Comment added (fixup never happens, we simply don't care).

symbol_exprt("__typeof__", code_typet({}, empty_typet())),
{},
typet{},
source_locationt{});

// if the return value is used, the next instruction will be assign
goto_programt::const_targett next=target;
Expand Down Expand Up @@ -486,9 +490,8 @@ goto_programt::const_targett goto_program2codet::convert_decl(
{
// could hack this by just erasing the first operand
const code_function_callt &f=to_code_function_call(next->code);
side_effect_expr_function_callt call;
call.function()=f.function();
call.arguments()=f.arguments();
side_effect_expr_function_callt call(
f.function(), f.arguments(), typet{}, source_locationt{});
d.copy_to_operands(call);
}

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

side_effect_expr_function_callt call;
call.add_source_location()=expr.source_location();
call.function()=symbol_expr;
call.type()=expr.type();
side_effect_expr_function_callt call(
symbol_expr, {}, expr.type(), expr.source_location());

expr.swap(call);
}
Expand Down
3 changes: 1 addition & 2 deletions src/jsil/parser.y
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,7 @@ instruction: TOK_LABEL TOK_IDENTIFIER
rhs: expression
| proc_ident_expr '(' expressions_opt ')' with_opt
{
side_effect_expr_function_callt f;
f.function().swap(stack($1));
side_effect_expr_function_callt f(stack($1), {}, typet{}, {});
if(stack($3).is_not_nil())
f.arguments().swap(stack($3).operands());

Expand Down