Skip to content

Commit f22a864

Browse files
author
Daniel Kroening
authored
Merge pull request #1386 from diffblue/return_directly
return STL containers directly for some variants of compute_called_functions
2 parents 2b050a0 + 428b985 commit f22a864

File tree

4 files changed

+31
-26
lines changed

4 files changed

+31
-26
lines changed

src/goto-analyzer/unreachable_instructions.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ void unreachable_instructions(
128128
{
129129
json_arrayt json_result;
130130

131-
std::set<irep_idt> called;
132-
compute_called_functions(goto_model, called);
131+
std::set<irep_idt> called=
132+
compute_called_functions(goto_model);
133133

134134
const namespacet ns(goto_model.symbol_table);
135135

@@ -191,8 +191,8 @@ static void list_functions(
191191
{
192192
json_arrayt json_result;
193193

194-
std::set<irep_idt> called;
195-
compute_called_functions(goto_model, called);
194+
std::set<irep_idt> called=
195+
compute_called_functions(goto_model);
196196

197197
const namespacet ns(goto_model.symbol_table);
198198

src/goto-programs/compute_called_functions.cpp

+17-7
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,22 @@ void compute_address_taken_functions(
6666
compute_address_taken_functions(it->second.body, address_taken);
6767
}
6868

69+
/// get all functions whose address is taken
70+
std::set<irep_idt> compute_address_taken_functions(
71+
const goto_functionst &goto_functions)
72+
{
73+
std::set<irep_idt> address_taken;
74+
compute_address_taken_functions(goto_functions, address_taken);
75+
return address_taken;
76+
}
77+
6978
/// computes the functions that are (potentially) called
70-
void compute_called_functions(
71-
const goto_functionst &goto_functions,
72-
std::set<irep_idt> &functions)
79+
std::set<irep_idt> compute_called_functions(
80+
const goto_functionst &goto_functions)
7381
{
7482
std::set<irep_idt> working_queue;
7583
std::set<irep_idt> done;
84+
std::set<irep_idt> functions;
7685

7786
// start from entry point
7887
working_queue.insert(goto_functions.entry_point());
@@ -109,12 +118,13 @@ void compute_called_functions(
109118
}
110119
}
111120
}
121+
122+
return functions;
112123
}
113124

114125
/// computes the functions that are (potentially) called
115-
void compute_called_functions(
116-
const goto_modelt &goto_model,
117-
std::set<irep_idt> &functions)
126+
std::set<irep_idt> compute_called_functions(
127+
const goto_modelt &goto_model)
118128
{
119-
compute_called_functions(goto_model.goto_functions, functions);
129+
return compute_called_functions(goto_model.goto_functions);
120130
}

src/goto-programs/compute_called_functions.h

+8-13
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,19 @@ Author: Daniel Kroening, [email protected]
1717
// compute the set of functions whose address is taken
1818

1919
void compute_address_taken_functions(
20-
const exprt &src,
21-
std::set<irep_idt> &address_taken);
20+
const exprt &,
21+
std::set<irep_idt> &);
2222

2323
void compute_address_taken_functions(
24-
const goto_programt &goto_program,
25-
std::set<irep_idt> &address_taken);
24+
const goto_programt &,
25+
std::set<irep_idt> &);
2626

2727
void compute_address_taken_functions(
28-
const goto_functionst &goto_functions,
29-
std::set<irep_idt> &address_taken);
30-
31-
// computes the functions that are (potentially) called
32-
void compute_called_functions(
3328
const goto_functionst &,
34-
std::set<irep_idt> &functions);
29+
std::set<irep_idt> &);
3530

36-
void compute_called_functions(
37-
const goto_modelt &,
38-
std::set<irep_idt> &functions);
31+
// computes the functions that are (potentially) called
32+
std::set<irep_idt> compute_called_functions(const goto_functionst &);
33+
std::set<irep_idt> compute_called_functions(const goto_modelt &);
3934

4035
#endif // CPROVER_GOTO_PROGRAMS_COMPUTE_CALLED_FUNCTIONS_H

src/goto-programs/link_to_library.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ void link_to_library(
4545

4646
while(true)
4747
{
48-
std::set<irep_idt> called_functions;
49-
compute_called_functions(goto_functions, called_functions);
48+
std::set<irep_idt> called_functions=
49+
compute_called_functions(goto_functions);
5050

5151
// eliminate those for which we already have a body
5252

0 commit comments

Comments
 (0)