Skip to content

Commit 3f951dd

Browse files
authored
Merge pull request diffblue#2234 from nmanthey/upstream-fpr
Upstream fpr
2 parents 34a3d85 + 52ab088 commit 3f951dd

File tree

5 files changed

+33
-37
lines changed

5 files changed

+33
-37
lines changed

src/goto-analyzer/unreachable_instructions.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@ void unreachable_instructions(
167167
{
168168
json_arrayt json_result;
169169

170-
std::set<irep_idt> called=
171-
compute_called_functions(goto_model);
170+
std::unordered_set<irep_idt> called = compute_called_functions(goto_model);
172171

173172
const namespacet ns(goto_model.symbol_table);
174173

@@ -291,7 +290,7 @@ static void xml_output_function(
291290

292291
static void list_functions(
293292
const goto_modelt &goto_model,
294-
const std::set<irep_idt> called,
293+
const std::unordered_set<irep_idt> &called,
295294
const optionst &options,
296295
std::ostream &os,
297296
bool unreachable)
@@ -387,7 +386,7 @@ void unreachable_functions(
387386
else
388387
options.set_option("text", true);
389388

390-
std::set<irep_idt> called = compute_called_functions(goto_model);
389+
std::unordered_set<irep_idt> called = compute_called_functions(goto_model);
391390

392391
list_functions(goto_model, called, options, os, true);
393392
}
@@ -403,17 +402,16 @@ void reachable_functions(
403402
else
404403
options.set_option("text", true);
405404

406-
std::set<irep_idt> called = compute_called_functions(goto_model);
405+
std::unordered_set<irep_idt> called = compute_called_functions(goto_model);
407406

408407
list_functions(goto_model, called, options, os, false);
409408
}
410409

411-
412-
std::set<irep_idt> compute_called_functions_from_ai(
410+
std::unordered_set<irep_idt> compute_called_functions_from_ai(
413411
const goto_modelt &goto_model,
414412
const ai_baset &ai)
415413
{
416-
std::set<irep_idt> called;
414+
std::unordered_set<irep_idt> called;
417415

418416
forall_goto_functions(f_it, goto_model.goto_functions)
419417
{
@@ -436,7 +434,8 @@ bool static_unreachable_functions(
436434
message_handlert &message_handler,
437435
std::ostream &out)
438436
{
439-
std::set<irep_idt> called = compute_called_functions_from_ai(goto_model, ai);
437+
std::unordered_set<irep_idt> called =
438+
compute_called_functions_from_ai(goto_model, ai);
440439

441440
list_functions(goto_model, called, options, out, true);
442441

@@ -450,7 +449,8 @@ bool static_reachable_functions(
450449
message_handlert &message_handler,
451450
std::ostream &out)
452451
{
453-
std::set<irep_idt> called = compute_called_functions_from_ai(goto_model, ai);
452+
std::unordered_set<irep_idt> called =
453+
compute_called_functions_from_ai(goto_model, ai);
454454

455455
list_functions(goto_model, called, options, out, false);
456456

src/goto-programs/compute_called_functions.cpp

+14-18
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Author: Daniel Kroening, [email protected]
1616
/// get all functions whose address is taken
1717
void compute_address_taken_functions(
1818
const exprt &src,
19-
std::set<irep_idt> &address_taken)
19+
std::unordered_set<irep_idt> &address_taken)
2020
{
2121
forall_operands(it, src)
2222
compute_address_taken_functions(*it, address_taken);
@@ -35,7 +35,7 @@ void compute_address_taken_functions(
3535
/// get all functions in the expression
3636
void compute_functions(
3737
const exprt &src,
38-
std::set<irep_idt> &address_taken)
38+
std::unordered_set<irep_idt> &address_taken)
3939
{
4040
forall_operands(it, src)
4141
compute_functions(*it, address_taken);
@@ -48,7 +48,7 @@ void compute_functions(
4848
/// get all functions whose address is taken
4949
void compute_address_taken_functions(
5050
const goto_programt &goto_program,
51-
std::set<irep_idt> &address_taken)
51+
std::unordered_set<irep_idt> &address_taken)
5252
{
5353
forall_goto_program_instructions(it, goto_program)
5454
{
@@ -60,28 +60,27 @@ void compute_address_taken_functions(
6060
/// get all functions whose address is taken
6161
void compute_address_taken_functions(
6262
const goto_functionst &goto_functions,
63-
std::set<irep_idt> &address_taken)
63+
std::unordered_set<irep_idt> &address_taken)
6464
{
6565
forall_goto_functions(it, goto_functions)
6666
compute_address_taken_functions(it->second.body, address_taken);
6767
}
6868

6969
/// get all functions whose address is taken
70-
std::set<irep_idt> compute_address_taken_functions(
71-
const goto_functionst &goto_functions)
70+
std::unordered_set<irep_idt>
71+
compute_address_taken_functions(const goto_functionst &goto_functions)
7272
{
73-
std::set<irep_idt> address_taken;
73+
std::unordered_set<irep_idt> address_taken;
7474
compute_address_taken_functions(goto_functions, address_taken);
7575
return address_taken;
7676
}
7777

7878
/// computes the functions that are (potentially) called
79-
std::set<irep_idt> compute_called_functions(
80-
const goto_functionst &goto_functions)
79+
std::unordered_set<irep_idt>
80+
compute_called_functions(const goto_functionst &goto_functions)
8181
{
82-
std::set<irep_idt> working_queue;
83-
std::set<irep_idt> done;
84-
std::set<irep_idt> functions;
82+
std::unordered_set<irep_idt> working_queue;
83+
std::unordered_set<irep_idt> functions;
8584

8685
// start from entry point
8786
working_queue.insert(goto_functions.entry_point());
@@ -91,12 +90,9 @@ std::set<irep_idt> compute_called_functions(
9190
irep_idt id=*working_queue.begin();
9291
working_queue.erase(working_queue.begin());
9392

94-
if(done.find(id)!=done.end())
93+
if(!functions.insert(id).second)
9594
continue;
9695

97-
functions.insert(id);
98-
done.insert(id);
99-
10096
const goto_functionst::function_mapt::const_iterator f_it=
10197
goto_functions.function_map.find(id);
10298

@@ -123,8 +119,8 @@ std::set<irep_idt> compute_called_functions(
123119
}
124120

125121
/// computes the functions that are (potentially) called
126-
std::set<irep_idt> compute_called_functions(
127-
const goto_modelt &goto_model)
122+
std::unordered_set<irep_idt>
123+
compute_called_functions(const goto_modelt &goto_model)
128124
{
129125
return compute_called_functions(goto_model.goto_functions);
130126
}

src/goto-programs/compute_called_functions.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,18 @@ Author: Daniel Kroening, [email protected]
1818

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

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

2727
void compute_address_taken_functions(
2828
const goto_functionst &,
29-
std::set<irep_idt> &);
29+
std::unordered_set<irep_idt> &);
3030

3131
// 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 &);
32+
std::unordered_set<irep_idt> compute_called_functions(const goto_functionst &);
33+
std::unordered_set<irep_idt> compute_called_functions(const goto_modelt &);
3434

3535
#endif // CPROVER_GOTO_PROGRAMS_COMPUTE_CALLED_FUNCTIONS_H

src/goto-programs/link_to_library.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ void link_to_library(
4545

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

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

src/goto-programs/remove_function_pointers.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class remove_function_pointerst:public messaget
6161
goto_programt &goto_program,
6262
goto_programt::targett target);
6363

64-
std::set<irep_idt> address_taken;
64+
std::unordered_set<irep_idt> address_taken;
6565

6666
typedef std::map<irep_idt, code_typet> type_mapt;
6767
type_mapt type_map;
@@ -80,8 +80,8 @@ class remove_function_pointerst:public messaget
8080
code_function_callt &function_call,
8181
goto_programt &dest);
8282

83-
void compute_address_taken_in_symbols(
84-
std::set<irep_idt> &address_taken)
83+
void
84+
compute_address_taken_in_symbols(std::unordered_set<irep_idt> &address_taken)
8585
{
8686
const symbol_tablet &symbol_table=ns.get_symbol_table();
8787

0 commit comments

Comments
 (0)