Skip to content

return STL containers directly for some variants of compute_called_functions #1386

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 1 commit into from
Sep 17, 2017
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
8 changes: 4 additions & 4 deletions src/goto-analyzer/unreachable_instructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,8 @@ void unreachable_instructions(
{
json_arrayt json_result;

std::set<irep_idt> called;
compute_called_functions(goto_model, called);
std::set<irep_idt> called=
compute_called_functions(goto_model);

const namespacet ns(goto_model.symbol_table);

Expand Down Expand Up @@ -191,8 +191,8 @@ static void list_functions(
{
json_arrayt json_result;

std::set<irep_idt> called;
compute_called_functions(goto_model, called);
std::set<irep_idt> called=
compute_called_functions(goto_model);

const namespacet ns(goto_model.symbol_table);

Expand Down
24 changes: 17 additions & 7 deletions src/goto-programs/compute_called_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<irep_idt> compute_address_taken_functions(
const goto_functionst &goto_functions)
{
std::set<irep_idt> 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<irep_idt> &functions)
std::set<irep_idt> compute_called_functions(
const goto_functionst &goto_functions)
{
std::set<irep_idt> working_queue;
std::set<irep_idt> done;
std::set<irep_idt> functions;

// start from entry point
working_queue.insert(goto_functions.entry_point());
Expand Down Expand Up @@ -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<irep_idt> &functions)
std::set<irep_idt> compute_called_functions(
const goto_modelt &goto_model)
{
compute_called_functions(goto_model.goto_functions, functions);
return compute_called_functions(goto_model.goto_functions);
}
21 changes: 8 additions & 13 deletions src/goto-programs/compute_called_functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,19 @@ Author: Daniel Kroening, [email protected]
// compute the set of functions whose address is taken

void compute_address_taken_functions(
const exprt &src,
std::set<irep_idt> &address_taken);
const exprt &,
std::set<irep_idt> &);

void compute_address_taken_functions(
const goto_programt &goto_program,
std::set<irep_idt> &address_taken);
const goto_programt &,
std::set<irep_idt> &);

void compute_address_taken_functions(
const goto_functionst &goto_functions,
std::set<irep_idt> &address_taken);

// computes the functions that are (potentially) called
void compute_called_functions(
const goto_functionst &,
std::set<irep_idt> &functions);
std::set<irep_idt> &);

void compute_called_functions(
const goto_modelt &,
std::set<irep_idt> &functions);
// computes the functions that are (potentially) called
std::set<irep_idt> compute_called_functions(const goto_functionst &);
std::set<irep_idt> compute_called_functions(const goto_modelt &);

#endif // CPROVER_GOTO_PROGRAMS_COMPUTE_CALLED_FUNCTIONS_H
4 changes: 2 additions & 2 deletions src/goto-programs/link_to_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ void link_to_library(

while(true)
{
std::set<irep_idt> called_functions;
compute_called_functions(goto_functions, called_functions);
std::set<irep_idt> called_functions=
compute_called_functions(goto_functions);

// eliminate those for which we already have a body

Expand Down