diff --git a/jbmc/src/java_bytecode/java_bytecode_convert_method.cpp b/jbmc/src/java_bytecode/java_bytecode_convert_method.cpp index 87055431405..bda33d32d09 100644 --- a/jbmc/src/java_bytecode/java_bytecode_convert_method.cpp +++ b/jbmc/src/java_bytecode/java_bytecode_convert_method.cpp @@ -2150,25 +2150,22 @@ void java_bytecode_convert_methodt::convert_invoke( } } - code_function_callt call; location.set_function(method_id); - call.add_source_location() = location; - call.arguments() = pop(parameters.size()); + code_function_callt::argumentst arguments = pop(parameters.size()); // double-check a bit - if(use_this) - { - const exprt &this_arg = call.arguments().front(); - INVARIANT( - this_arg.type().id() == ID_pointer, "first argument must be a pointer"); - } + INVARIANT( + !use_this || arguments.front().type().id() == ID_pointer, + "first argument must be a pointer"); // do some type adjustment for the arguments, // as Java promotes arguments // Also cast pointers since intermediate locals // can be void*. - + INVARIANT( + parameters.size() == arguments.size(), + "for each parameter there must be exactly one argument"); for(std::size_t i = 0; i < parameters.size(); i++) { const typet &type = parameters[i].type(); @@ -2177,21 +2174,20 @@ void java_bytecode_convert_methodt::convert_invoke( type == java_byte_type() || type == java_short_type() || type.id() == ID_pointer) { - assert(i < call.arguments().size()); - if(type != call.arguments()[i].type()) - call.arguments()[i].make_typecast(type); + if(type != arguments[i].type()) + arguments[i].make_typecast(type); } } // do some type adjustment for return values - + exprt lhs = nil_exprt(); const typet &return_type = method_type.return_type(); if(return_type.id() != ID_empty) { // return types are promoted in Java - call.lhs() = tmp_variable("return", return_type); - exprt promoted = java_bytecode_promotion(call.lhs()); + lhs = tmp_variable("return", return_type); + exprt promoted = java_bytecode_promotion(lhs); results.resize(1); results[0] = promoted; } @@ -2233,19 +2229,20 @@ void java_bytecode_convert_methodt::convert_invoke( symbol_table.add(symbol); } + exprt function; if(is_virtual) { // dynamic binding - assert(use_this); - assert(!call.arguments().empty()); - call.function() = arg0; + PRECONDITION(use_this); + PRECONDITION(!arguments.empty()); + function = arg0; // Populate needed methods later, // once we know what object types can exist. } else { // static binding - call.function() = symbol_exprt(invoked_method_id, method_type); + function = symbol_exprt(invoked_method_id, method_type); if(needed_lazy_methods) { needed_lazy_methods->add_needed_method(invoked_method_id); @@ -2254,6 +2251,9 @@ void java_bytecode_convert_methodt::convert_invoke( } } + code_function_callt call( + std::move(lhs), std::move(function), std::move(arguments)); + call.add_source_location() = location; call.function().add_source_location() = location; // Replacing call if it is a function of the Character library, diff --git a/src/goto-analyzer/taint_analysis.cpp b/src/goto-analyzer/taint_analysis.cpp index be2e88769c0..297d521f371 100644 --- a/src/goto-analyzer/taint_analysis.cpp +++ b/src/goto-analyzer/taint_analysis.cpp @@ -284,8 +284,9 @@ bool taint_analysist::operator()( if(f_it->second.body_available() && f_it->first!=goto_functionst::entry_point()) { + const symbolt &symbol = ns.lookup(f_it->first); goto_programt::targett t=calls.add_instruction(); - const code_function_callt call(ns.lookup(f_it->first).symbol_expr()); + const code_function_callt call(symbol.symbol_expr()); t->make_function_call(call); calls.add_instruction()->make_goto(end.instructions.begin()); goto_programt::targett g=gotos.add_instruction(); diff --git a/src/goto-programs/remove_asm.cpp b/src/goto-programs/remove_asm.cpp index 3d43be4e756..c7a3cd78d37 100644 --- a/src/goto-programs/remove_asm.cpp +++ b/src/goto-programs/remove_asm.cpp @@ -76,8 +76,7 @@ void remove_asmt::gcc_asm_function_call( { irep_idt function_identifier=function_base_name; - code_function_callt function_call; - function_call.lhs().make_nil(); + code_function_callt::argumentst arguments; const typet void_pointer= pointer_type(void_typet()); @@ -87,7 +86,7 @@ void remove_asmt::gcc_asm_function_call( { if(it->operands().size()==2) { - function_call.arguments().push_back( + arguments.push_back( typecast_exprt(address_of_exprt(it->op1()), void_pointer)); } } @@ -97,7 +96,7 @@ void remove_asmt::gcc_asm_function_call( { if(it->operands().size()==2) { - function_call.arguments().push_back( + arguments.push_back( typecast_exprt(address_of_exprt(it->op1()), void_pointer)); } } @@ -107,7 +106,7 @@ void remove_asmt::gcc_asm_function_call( symbol_exprt fkt(function_identifier, fkt_type); - function_call.function()=fkt; + code_function_callt function_call(std::move(fkt), std::move(arguments)); goto_programt::targett call=dest.add_instruction(FUNCTION_CALL); call->code=function_call; diff --git a/unit/analyses/ai/ai.cpp b/unit/analyses/ai/ai.cpp index 58cfa0ccac3..3440005ae68 100644 --- a/unit/analyses/ai/ai.cpp +++ b/unit/analyses/ai/ai.cpp @@ -111,9 +111,7 @@ class instruction_counter_analysist : public ait static code_function_callt make_void_call(const symbol_exprt &function) { - code_function_callt ret; - ret.function() = function; - return ret; + return code_function_callt(function, {}); } SCENARIO(