diff --git a/src/goto-analyzer/unreachable_instructions.cpp b/src/goto-analyzer/unreachable_instructions.cpp index 44a4e8cd9bf..c852ca7f6c2 100644 --- a/src/goto-analyzer/unreachable_instructions.cpp +++ b/src/goto-analyzer/unreachable_instructions.cpp @@ -128,8 +128,8 @@ void unreachable_instructions( { json_arrayt json_result; - std::set called; - compute_called_functions(goto_model, called); + std::set called= + compute_called_functions(goto_model); const namespacet ns(goto_model.symbol_table); @@ -191,8 +191,8 @@ static void list_functions( { json_arrayt json_result; - std::set called; - compute_called_functions(goto_model, called); + std::set called= + compute_called_functions(goto_model); const namespacet ns(goto_model.symbol_table); diff --git a/src/goto-programs/compute_called_functions.cpp b/src/goto-programs/compute_called_functions.cpp index 36e2b7a1a8b..774325ab904 100644 --- a/src/goto-programs/compute_called_functions.cpp +++ b/src/goto-programs/compute_called_functions.cpp @@ -66,13 +66,22 @@ void compute_address_taken_functions( compute_address_taken_functions(it->second.body, address_taken); } +/// get all functions whose address is taken +std::set compute_address_taken_functions( + const goto_functionst &goto_functions) +{ + std::set address_taken; + compute_address_taken_functions(goto_functions, address_taken); + return address_taken; +} + /// computes the functions that are (potentially) called -void compute_called_functions( - const goto_functionst &goto_functions, - std::set &functions) +std::set compute_called_functions( + const goto_functionst &goto_functions) { std::set working_queue; std::set done; + std::set functions; // start from entry point working_queue.insert(goto_functions.entry_point()); @@ -109,12 +118,13 @@ void compute_called_functions( } } } + + return functions; } /// computes the functions that are (potentially) called -void compute_called_functions( - const goto_modelt &goto_model, - std::set &functions) +std::set compute_called_functions( + const goto_modelt &goto_model) { - compute_called_functions(goto_model.goto_functions, functions); + return compute_called_functions(goto_model.goto_functions); } diff --git a/src/goto-programs/compute_called_functions.h b/src/goto-programs/compute_called_functions.h index 6f92b420b37..c11d16921c5 100644 --- a/src/goto-programs/compute_called_functions.h +++ b/src/goto-programs/compute_called_functions.h @@ -17,24 +17,19 @@ Author: Daniel Kroening, kroening@kroening.com // compute the set of functions whose address is taken void compute_address_taken_functions( - const exprt &src, - std::set &address_taken); + const exprt &, + std::set &); void compute_address_taken_functions( - const goto_programt &goto_program, - std::set &address_taken); + const goto_programt &, + std::set &); void compute_address_taken_functions( - const goto_functionst &goto_functions, - std::set &address_taken); - -// computes the functions that are (potentially) called -void compute_called_functions( const goto_functionst &, - std::set &functions); + std::set &); -void compute_called_functions( - const goto_modelt &, - std::set &functions); +// computes the functions that are (potentially) called +std::set compute_called_functions(const goto_functionst &); +std::set compute_called_functions(const goto_modelt &); #endif // CPROVER_GOTO_PROGRAMS_COMPUTE_CALLED_FUNCTIONS_H diff --git a/src/goto-programs/link_to_library.cpp b/src/goto-programs/link_to_library.cpp index 2464aca83fe..9bb9e0d75bd 100644 --- a/src/goto-programs/link_to_library.cpp +++ b/src/goto-programs/link_to_library.cpp @@ -45,8 +45,8 @@ void link_to_library( while(true) { - std::set called_functions; - compute_called_functions(goto_functions, called_functions); + std::set called_functions= + compute_called_functions(goto_functions); // eliminate those for which we already have a body