Skip to content

Commit dc2b436

Browse files
author
Owen Jones
committed
Remove redundant irep_id_hash for sets
Also stop using typedefs for std::set<irep_idt> and std::unordered_set<irep_idt>. Fixes: diffblue#2090
1 parent 3e2ab6f commit dc2b436

39 files changed

+121
-131
lines changed

src/analyses/dirty.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class dirtyt
3434

3535
public:
3636
bool initialized;
37-
typedef std::unordered_set<irep_idt, irep_id_hash> id_sett;
3837
typedef goto_functionst::goto_functiont goto_functiont;
3938

4039
/// \post dirtyt objects that are created through this constructor are not
@@ -72,7 +71,7 @@ class dirtyt
7271
return operator()(expr.get_identifier());
7372
}
7473

75-
const id_sett &get_dirty_ids() const
74+
const std::unordered_set<irep_idt> &get_dirty_ids() const
7675
{
7776
die_if_uninitialized();
7877
return dirty;
@@ -97,7 +96,7 @@ class dirtyt
9796
void build(const goto_functiont &goto_function);
9897

9998
// variables whose address is taken
100-
id_sett dirty;
99+
std::unordered_set<irep_idt> dirty;
101100

102101
void find_dirty(const exprt &expr);
103102
void find_dirty_address_of(const exprt &expr);
@@ -131,7 +130,7 @@ class incremental_dirtyt
131130

132131
private:
133132
dirtyt dirty;
134-
std::unordered_set<irep_idt, irep_id_hash> dirty_processed_functions;
133+
std::unordered_set<irep_idt> dirty_processed_functions;
135134
};
136135

137136
#endif // CPROVER_ANALYSES_DIRTY_H

src/ansi-c/c_typecheck_type.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -877,7 +877,7 @@ void c_typecheck_baset::typecheck_compound_body(
877877
// scan for duplicate members
878878

879879
{
880-
std::unordered_set<irep_idt, irep_id_hash> members;
880+
std::unordered_set<irep_idt> members;
881881

882882
for(struct_union_typet::componentst::iterator
883883
it=components.begin();

src/ansi-c/expr2c_class.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,8 @@ class expr2ct
6464

6565
static std::string indent_str(unsigned indent);
6666

67-
std::unordered_map<irep_idt,
68-
std::unordered_set<irep_idt, irep_id_hash>,
69-
irep_id_hash> ns_collision;
67+
std::unordered_map<irep_idt, std::unordered_set<irep_idt>, irep_id_hash>
68+
ns_collision;
7069
std::unordered_map<irep_idt, irep_idt, irep_id_hash> shorthands;
7170

7271
unsigned sizeof_nesting;

src/cbmc/symex_bmc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class symex_bmct: public goto_symext
147147

148148
virtual void no_body(const irep_idt &identifier);
149149

150-
std::unordered_set<irep_idt, irep_id_hash> body_warnings;
150+
std::unordered_set<irep_idt> body_warnings;
151151

152152
symex_coveraget symex_coverage;
153153
};

src/goto-diff/goto_diff.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,19 @@ class goto_difft:public messaget
5151
ui_message_handlert::uit ui;
5252

5353
unsigned total_functions_count;
54-
typedef std::set<irep_idt> irep_id_sett;
55-
irep_id_sett new_functions, modified_functions, deleted_functions;
54+
std::set<irep_idt> new_functions, modified_functions, deleted_functions;
5655

5756
void output_function_group(
5857
const std::string &group_name,
59-
const irep_id_sett &function_group,
58+
const std::set<irep_idt> &function_group,
6059
const goto_modelt &goto_model) const;
6160
void output_function(
6261
const irep_idt &function_name,
6362
const goto_modelt &goto_model) const;
6463

6564
void convert_function_group_json(
6665
json_arrayt &result,
67-
const irep_id_sett &function_group,
66+
const std::set<irep_idt> &function_group,
6867
const goto_modelt &goto_model) const;
6968
void convert_function_json(
7069
json_objectt &result,

src/goto-diff/goto_diff_base.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void goto_difft::output_functions() const
6464
/// \param goto_model: the goto model
6565
void goto_difft::output_function_group(
6666
const std::string &group_name,
67-
const irep_id_sett &function_group,
67+
const std::set<irep_idt> &function_group,
6868
const goto_modelt &goto_model) const
6969
{
7070
result() << group_name << ":\n";
@@ -113,7 +113,7 @@ void goto_difft::output_function(
113113
/// \param goto_model: the goto model
114114
void goto_difft::convert_function_group_json(
115115
json_arrayt &result,
116-
const irep_id_sett &function_group,
116+
const std::set<irep_idt> &function_group,
117117
const goto_modelt &goto_model) const
118118
{
119119
for(const auto &function_name : function_group)

src/goto-instrument/code_contracts.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@ class code_contractst
4545

4646
unsigned temporary_counter;
4747

48-
typedef std::unordered_set<irep_idt, irep_id_hash> id_sett;
49-
id_sett summarized;
48+
std::unordered_set<irep_idt> summarized;
5049

5150
void code_contracts(goto_functionst::goto_functiont &goto_function);
5251

@@ -389,8 +388,8 @@ void code_contractst::operator()()
389388
goto_functions.function_map.find(CPROVER_PREFIX "initialize");
390389
assert(i_it!=goto_functions.function_map.end());
391390

392-
for(id_sett::const_iterator it=summarized.begin();
393-
it!=summarized.end();
391+
for(std::unordered_set<irep_idt>::const_iterator it = summarized.begin();
392+
it != summarized.end();
394393
++it)
395394
add_contract_check(*it, i_it->second.body);
396395

src/goto-instrument/count_eloc.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Date: December 2012
2121

2222
#include <goto-programs/cfg.h>
2323

24-
typedef std::unordered_set<irep_idt, irep_id_hash> linest;
24+
typedef std::unordered_set<irep_idt> linest;
2525
typedef std::unordered_map<irep_idt, linest, irep_id_hash> filest;
2626
typedef std::unordered_map<irep_idt, filest, irep_id_hash> working_dirst;
2727

src/goto-instrument/dump_c.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ void dump_ct::cleanup_decl(
613613

614614
tmp.add_instruction(END_FUNCTION);
615615

616-
std::unordered_set<irep_idt, irep_id_hash> typedef_names;
616+
std::unordered_set<irep_idt> typedef_names;
617617
for(const auto &td : typedef_map)
618618
typedef_names.insert(td.first);
619619

@@ -640,7 +640,7 @@ void dump_ct::cleanup_decl(
640640
/// function declarations or struct definitions
641641
void dump_ct::collect_typedefs(const typet &type, bool early)
642642
{
643-
std::unordered_set<irep_idt, irep_id_hash> deps;
643+
std::unordered_set<irep_idt> deps;
644644
collect_typedefs_rec(type, early, deps);
645645
}
646646

@@ -654,12 +654,12 @@ void dump_ct::collect_typedefs(const typet &type, bool early)
654654
void dump_ct::collect_typedefs_rec(
655655
const typet &type,
656656
bool early,
657-
std::unordered_set<irep_idt, irep_id_hash> &dependencies)
657+
std::unordered_set<irep_idt> &dependencies)
658658
{
659659
if(system_symbols.is_type_internal(type, system_headers))
660660
return;
661661

662-
std::unordered_set<irep_idt, irep_id_hash> local_deps;
662+
std::unordered_set<irep_idt> local_deps;
663663

664664
if(type.id()==ID_code)
665665
{
@@ -769,9 +769,8 @@ void dump_ct::dump_typedefs(std::ostream &os) const
769769
// output
770770
std::map<std::string, typedef_infot> to_insert;
771771

772-
typedef std::unordered_set<irep_idt, irep_id_hash> id_sett;
773-
id_sett typedefs_done;
774-
std::unordered_map<irep_idt, id_sett, irep_id_hash>
772+
std::unordered_set<irep_idt> typedefs_done;
773+
std::unordered_map<irep_idt, std::unordered_set<irep_idt>, irep_id_hash>
775774
forward_deps, reverse_deps;
776775

777776
for(const auto &td : typedef_map)
@@ -805,8 +804,9 @@ void dump_ct::dump_typedefs(std::ostream &os) const
805804
continue;
806805

807806
// reduce remaining dependencies
808-
id_sett &r_deps=r_it->second;
809-
for(id_sett::iterator it=r_deps.begin(); it!=r_deps.end(); ) // no ++it
807+
std::unordered_set<irep_idt> &r_deps = r_it->second;
808+
for(std::unordered_set<irep_idt>::iterator it = r_deps.begin();
809+
it != r_deps.end();) // no ++it
810810
{
811811
auto f_it=forward_deps.find(*it);
812812
if(f_it==forward_deps.end()) // might be done already
@@ -816,7 +816,7 @@ void dump_ct::dump_typedefs(std::ostream &os) const
816816
}
817817

818818
// update dependencies
819-
id_sett &f_deps=f_it->second;
819+
std::unordered_set<irep_idt> &f_deps = f_it->second;
820820
PRECONDITION(!f_deps.empty());
821821
PRECONDITION(f_deps.find(t.typedef_name)!=f_deps.end());
822822
f_deps.erase(t.typedef_name);
@@ -986,7 +986,7 @@ void dump_ct::convert_function_declaration(
986986
code_blockt b;
987987
std::list<irep_idt> type_decls, local_static;
988988

989-
std::unordered_set<irep_idt, irep_id_hash> typedef_names;
989+
std::unordered_set<irep_idt> typedef_names;
990990
for(const auto &td : typedef_map)
991991
typedef_names.insert(td.first);
992992

src/goto-instrument/dump_c_class.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class dump_ct
5252
std::unique_ptr<languaget> language;
5353
const bool harness;
5454

55-
typedef std::unordered_set<irep_idt, irep_id_hash> convertedt;
55+
typedef std::unordered_set<irep_idt> convertedt;
5656
convertedt converted_compound, converted_global, converted_enum;
5757

5858
std::set<std::string> system_headers;
@@ -68,7 +68,7 @@ class dump_ct
6868
irep_idt typedef_name;
6969
std::string type_decl_str;
7070
bool early;
71-
std::unordered_set<irep_idt, irep_id_hash> dependencies;
71+
std::unordered_set<irep_idt> dependencies;
7272

7373
explicit typedef_infot(const irep_idt &name):
7474
typedef_name(name),
@@ -108,7 +108,7 @@ class dump_ct
108108
void collect_typedefs_rec(
109109
const typet &type,
110110
bool early,
111-
std::unordered_set<irep_idt, irep_id_hash> &dependencies);
111+
std::unordered_set<irep_idt> &dependencies);
112112
void gather_global_typedefs();
113113
void dump_typedefs(std::ostream &os) const;
114114

src/goto-instrument/goto_program2code.h

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ Author: Daniel Kroening, [email protected]
2020
class goto_program2codet
2121
{
2222
typedef std::list<irep_idt> id_listt;
23-
typedef std::unordered_set<irep_idt, irep_id_hash> id_sett;
2423
typedef std::map<goto_programt::const_targett, goto_programt::const_targett>
2524
loopt;
2625
typedef std::unordered_map<irep_idt, unsigned, irep_id_hash> dead_mapt;
@@ -47,23 +46,23 @@ class goto_program2codet
4746

4847
public:
4948
goto_program2codet(
50-
const irep_idt &identifier,
51-
const goto_programt &_goto_program,
52-
symbol_tablet &_symbol_table,
53-
code_blockt &_dest,
54-
id_listt &_local_static,
55-
id_listt &_type_names,
56-
const id_sett &_typedef_names,
57-
std::set<std::string> &_system_headers):
58-
func_name(identifier),
59-
goto_program(_goto_program),
60-
symbol_table(_symbol_table),
61-
ns(_symbol_table),
62-
toplevel_block(_dest),
63-
local_static(_local_static),
64-
type_names(_type_names),
65-
typedef_names(_typedef_names),
66-
system_headers(_system_headers)
49+
const irep_idt &identifier,
50+
const goto_programt &_goto_program,
51+
symbol_tablet &_symbol_table,
52+
code_blockt &_dest,
53+
id_listt &_local_static,
54+
id_listt &_type_names,
55+
const std::unordered_set<irep_idt> &_typedef_names,
56+
std::set<std::string> &_system_headers)
57+
: func_name(identifier),
58+
goto_program(_goto_program),
59+
symbol_table(_symbol_table),
60+
ns(_symbol_table),
61+
toplevel_block(_dest),
62+
local_static(_local_static),
63+
type_names(_type_names),
64+
typedef_names(_typedef_names),
65+
system_headers(_system_headers)
6766
{
6867
assert(local_static.empty());
6968

@@ -84,18 +83,18 @@ class goto_program2codet
8483
code_blockt &toplevel_block;
8584
id_listt &local_static;
8685
id_listt &type_names;
87-
const id_sett &typedef_names;
86+
const std::unordered_set<irep_idt> &typedef_names;
8887
std::set<std::string> &system_headers;
8988
std::unordered_set<exprt, irep_hash> va_list_expr;
9089

9190
natural_loopst loops;
9291
loopt loop_map;
93-
id_sett labels_in_use;
92+
std::unordered_set<irep_idt> labels_in_use;
9493
dead_mapt dead_map;
9594
loop_last_stackt loop_last_stack;
96-
id_sett local_static_set;
97-
id_sett type_names_set;
98-
id_sett const_removed;
95+
std::unordered_set<irep_idt> local_static_set;
96+
std::unordered_set<irep_idt> type_names_set;
97+
std::unordered_set<irep_idt> const_removed;
9998

10099
void build_loop_map();
101100
void build_dead_map();

src/goto-programs/goto_inline_class.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,13 +193,13 @@ class goto_inlinet:public messaget
193193
typedef goto_functionst::function_mapt cachet;
194194
cachet cache;
195195

196-
typedef std::unordered_set<irep_idt, irep_id_hash> finished_sett;
196+
typedef std::unordered_set<irep_idt> finished_sett;
197197
finished_sett finished_set;
198198

199-
typedef std::unordered_set<irep_idt, irep_id_hash> recursion_sett;
199+
typedef std::unordered_set<irep_idt> recursion_sett;
200200
recursion_sett recursion_set;
201201

202-
typedef std::unordered_set<irep_idt, irep_id_hash> no_body_sett;
202+
typedef std::unordered_set<irep_idt> no_body_sett;
203203
no_body_sett no_body_set;
204204
};
205205

src/goto-programs/lazy_goto_functions_map.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class lazy_goto_functions_mapt final
6161
/// Names of functions that are already fully available in the programt state.
6262
/// \remarks These functions do not need processing before being returned
6363
/// whenever they are requested
64-
mutable std::unordered_set<irep_idt, irep_id_hash> processed_functions;
64+
mutable std::unordered_set<irep_idt> processed_functions;
6565

6666
language_filest &language_files;
6767
symbol_tablet &symbol_table;

src/goto-programs/link_goto_model.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static bool link_functions(
4747
const symbol_tablet &src_symbol_table,
4848
goto_functionst &src_functions,
4949
const rename_symbolt &rename_symbol,
50-
const std::unordered_set<irep_idt, irep_id_hash> &weak_symbols,
50+
const std::unordered_set<irep_idt> &weak_symbols,
5151
const replace_symbolt &object_type_updates)
5252
{
5353
namespacet ns(dest_symbol_table);
@@ -158,8 +158,7 @@ void link_goto_model(
158158
goto_modelt &src,
159159
message_handlert &message_handler)
160160
{
161-
typedef std::unordered_set<irep_idt, irep_id_hash> id_sett;
162-
id_sett weak_symbols;
161+
std::unordered_set<irep_idt> weak_symbols;
163162

164163
for(const auto &symbol_pair : dest.symbol_table.symbols)
165164
{

src/goto-programs/set_properties.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Author: Daniel Kroening, [email protected]
1616

1717
void set_properties(
1818
goto_programt &goto_program,
19-
std::unordered_set<irep_idt, irep_id_hash> &property_set)
19+
std::unordered_set<irep_idt> &property_set)
2020
{
2121
for(goto_programt::instructionst::iterator
2222
it=goto_program.instructions.begin();
@@ -28,8 +28,8 @@ void set_properties(
2828

2929
irep_idt property_id=it->source_location.get_property_id();
3030

31-
std::unordered_set<irep_idt, irep_id_hash>::iterator
32-
c_it=property_set.find(property_id);
31+
std::unordered_set<irep_idt>::iterator c_it =
32+
property_set.find(property_id);
3333

3434
if(c_it==property_set.end())
3535
it->type=SKIP;
@@ -102,7 +102,7 @@ void set_properties(
102102
goto_functionst &goto_functions,
103103
const std::list<std::string> &properties)
104104
{
105-
std::unordered_set<irep_idt, irep_id_hash> property_set;
105+
std::unordered_set<irep_idt> property_set;
106106

107107
property_set.insert(properties.begin(), properties.end());
108108

src/goto-symex/partial_order_concurrency.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ partial_order_concurrencyt::~partial_order_concurrencyt()
2828
void partial_order_concurrencyt::add_init_writes(
2929
symex_target_equationt &equation)
3030
{
31-
std::unordered_set<irep_idt, irep_id_hash> init_done;
31+
std::unordered_set<irep_idt> init_done;
3232
bool spawn_seen=false;
3333

3434
symex_target_equationt::SSA_stepst init_steps;

0 commit comments

Comments
 (0)