Skip to content

Commit b231a4f

Browse files
authored
Merge pull request #3048 from diffblue/function_application_exprt-constructors
complete constructors for function_application_exprt
2 parents 03126ae + df1ee1c commit b231a4f

File tree

7 files changed

+33
-60
lines changed

7 files changed

+33
-60
lines changed

jbmc/src/java_bytecode/java_utils.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,7 @@ exprt make_function_application(
285285
declare_function(fun_name, type, symbol_table);
286286

287287
// Function application
288-
function_application_exprt call(symbol_exprt(fun_name), type);
289-
call.arguments()=arguments;
290-
return call;
288+
return function_application_exprt(symbol_exprt(fun_name), arguments, type);
291289
}
292290

293291
/// Strip java:: prefix from given identifier

jbmc/unit/solvers/refinement/string_constraint_instantiation/instantiate_not_contains.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -186,10 +186,10 @@ SCENARIO("instantiate_not_contains",
186186
GIVEN("The not_contains axioms of String.lastIndexOf(String, Int)")
187187
{
188188
// Creating "ab".lastIndexOf("b", 0)
189-
function_application_exprt func(
190-
symbol_exprt(ID_cprover_string_last_index_of_func), t.length_type());
191-
const exprt::operandst args={ab, b, from_integer(2)};
192-
func.arguments()=args;
189+
const function_application_exprt func(
190+
symbol_exprt(ID_cprover_string_last_index_of_func),
191+
{ab, b, from_integer(2)},
192+
t.length_type());
193193

194194
// Generating the corresponding axioms and simplifying, recording info
195195
symbol_tablet symtab;

jbmc/unit/solvers/refinement/string_refinement/dependency_graph.cpp

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,22 @@ SCENARIO("dependency_graph", "[core][solvers][refinement][string_refinement]")
6666
unsignedbv_typet(32));
6767

6868
// fun1 is s3 = s1.concat(s2)
69-
function_application_exprt fun1(fun_type);
70-
fun1.function() = symbol_exprt(ID_cprover_string_concat_func);
71-
fun1.arguments().push_back(string3.op0());
72-
fun1.arguments().push_back(string3.op1());
73-
fun1.arguments().push_back(string1);
74-
fun1.arguments().push_back(string2);
69+
const function_application_exprt fun1(
70+
symbol_exprt(ID_cprover_string_concat_func),
71+
{string3.op0(), string3.op1(), string1, string2},
72+
fun_type);
7573

7674
// fun2 is s5 = s3.concat(s4)
77-
function_application_exprt fun2(fun_type);
78-
fun2.function() = symbol_exprt(ID_cprover_string_concat_func);
79-
fun2.arguments().push_back(string5.op0());
80-
fun2.arguments().push_back(string5.op1());
81-
fun2.arguments().push_back(string3);
82-
fun2.arguments().push_back(string4);
75+
const function_application_exprt fun2(
76+
symbol_exprt(ID_cprover_string_concat_func),
77+
{string5.op0(), string5.op1(), string3, string4},
78+
fun_type);
8379

8480
// fun3 is s6 = s5.concat(s2)
85-
function_application_exprt fun3(fun_type);
86-
fun3.function() = symbol_exprt(ID_cprover_string_concat_func);
87-
fun3.arguments().push_back(string6.op0());
88-
fun3.arguments().push_back(string6.op1());
89-
fun3.arguments().push_back(string5);
90-
fun3.arguments().push_back(string2);
81+
const function_application_exprt fun3(
82+
symbol_exprt(ID_cprover_string_concat_func),
83+
{string6.op0(), string6.op1(), string5, string2},
84+
fun_type);
9185

9286
const equal_exprt equation1(lhs, fun1);
9387
const equal_exprt equation2(lhs2, fun2);

jbmc/unit/solvers/refinement/string_refinement/string_symbol_resolution.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ SCENARIO("string_identifiers_resolution_from_equations",
6868
typet return_type;
6969
symbol_exprt fun_sym(
7070
"f", java_method_typet(std::move(parameters), return_type));
71-
function_application_exprt fun(fun_sym, bool_typet());
72-
fun.operands().push_back(c);
71+
const function_application_exprt fun(fun_sym, {c}, bool_typet());
7372
symbol_exprt bool_sym("bool_b", bool_typet());
7473
equations.emplace_back(bool_sym, fun);
7574
union_find_replacet symbol_resolve =

src/goto-programs/builtin_functions.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -900,11 +900,7 @@ void goto_convertt::do_function_call_symbol(
900900
if(lhs.is_nil())
901901
return;
902902

903-
function_application_exprt rhs;
904-
rhs.type()=lhs.type();
905-
rhs.add_source_location()=function.source_location();
906-
rhs.function()=function;
907-
rhs.arguments()=arguments;
903+
const function_application_exprt rhs(function, arguments, lhs.type());
908904

909905
code_assignt assignment(lhs, rhs);
910906
assignment.add_source_location()=function.source_location();

src/solvers/smt2/smt2_parser.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -286,11 +286,6 @@ exprt smt2_parsert::function_application(
286286
#if 0
287287
const auto &f = id_map[identifier];
288288

289-
function_application_exprt result;
290-
291-
result.function()=symbol_exprt(identifier, f.type);
292-
result.arguments()=op;
293-
294289
// check the arguments
295290
if(op.size()!=f.type.variables().size())
296291
{
@@ -303,12 +298,12 @@ exprt smt2_parsert::function_application(
303298
if(op[i].type() != f.type.variables()[i].type())
304299
{
305300
error() << "wrong type for arguments for function" << eom;
306-
return result;
301+
return nil_exprt();
307302
}
308303
}
309304

310-
result.type()=f.type.range();
311-
return result;
305+
return function_application_exprt(
306+
symbol_exprt(identifier, f.type), op, f.type.range());
312307
#endif
313308
return nil_exprt();
314309
}
@@ -675,12 +670,11 @@ exprt smt2_parsert::function_application()
675670
{
676671
if(id_it->second.type.id()==ID_mathematical_function)
677672
{
678-
function_application_exprt app;
679-
app.function()=symbol_exprt(final_id, id_it->second.type);
680-
app.arguments()=op;
681-
app.type()=to_mathematical_function_type(
682-
id_it->second.type).codomain();
683-
return app;
673+
return function_application_exprt(
674+
symbol_exprt(final_id, id_it->second.type),
675+
op,
676+
to_mathematical_function_type(
677+
id_it->second.type).codomain());
684678
}
685679
else
686680
return symbol_exprt(final_id, id_it->second.type);

src/util/std_expr.h

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4333,22 +4333,16 @@ class null_pointer_exprt:public constant_exprt
43334333
class function_application_exprt:public binary_exprt
43344334
{
43354335
public:
4336-
function_application_exprt():binary_exprt(ID_function_application)
4337-
{
4338-
op0()=symbol_exprt();
4339-
}
4340-
4341-
explicit function_application_exprt(const typet &_type):
4342-
binary_exprt(ID_function_application, _type)
4343-
{
4344-
op0()=symbol_exprt();
4345-
}
4336+
using argumentst = exprt::operandst;
43464337

43474338
function_application_exprt(
4348-
const symbol_exprt &_function, const typet &_type):
4349-
function_application_exprt(_type) // NOLINT(runtime/explicit)
4339+
const symbol_exprt &_function,
4340+
const argumentst &_arguments,
4341+
const typet &_type)
4342+
: binary_exprt(ID_function_application, _type)
43504343
{
43514344
function()=_function;
4345+
arguments() = _arguments;
43524346
}
43534347

43544348
symbol_exprt &function()
@@ -4361,8 +4355,6 @@ class function_application_exprt:public binary_exprt
43614355
return static_cast<const symbol_exprt &>(op0());
43624356
}
43634357

4364-
typedef exprt::operandst argumentst;
4365-
43664358
argumentst &arguments()
43674359
{
43684360
return op1().operands();

0 commit comments

Comments
 (0)