Skip to content

Commit 706e391

Browse files
author
Daniel Kroening
authored
Merge pull request diffblue#2093 from owen-jones-diffblue/owen-jones-diffblue/remove_unnecessary_irep_id_hash
Remove unnecessary uses of irep_id_hash
2 parents 290feb4 + e28a662 commit 706e391

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+173
-216
lines changed

src/analyses/call_graph.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ class function_indicest
172172
call_grapht::directed_grapht &graph;
173173

174174
public:
175-
std::unordered_map<irep_idt, node_indext, irep_id_hash> function_indices;
175+
std::unordered_map<irep_idt, node_indext> function_indices;
176176

177177
explicit function_indicest(call_grapht::directed_grapht &graph):
178178
graph(graph)

src/analyses/call_graph.h

+2-3
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ class call_grapht
119119
friend class call_grapht;
120120

121121
/// Maps function names onto node indices
122-
std::unordered_map<irep_idt, node_indext, irep_id_hash> nodes_by_name;
122+
std::unordered_map<irep_idt, node_indext> nodes_by_name;
123123

124124
public:
125125
/// Find the graph node by function name
@@ -128,8 +128,7 @@ class call_grapht
128128
optionalt<node_indext> get_node_index(const irep_idt &function) const;
129129

130130
/// Type of the node name -> node index map.
131-
typedef
132-
std::unordered_map<irep_idt, node_indext, irep_id_hash> nodes_by_namet;
131+
typedef std::unordered_map<irep_idt, node_indext> nodes_by_namet;
133132

134133
/// Get the node name -> node index map
135134
/// \return node-by-name map

src/analyses/dirty.h

+3-4
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/analyses/invariant_propagation.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,7 @@ void invariant_propagationt::add_objects(
4040
goto_program.get_decl_identifiers(locals);
4141

4242
// cache the list for the locals to speed things up
43-
typedef std::unordered_map<irep_idt, object_listt, irep_id_hash>
44-
object_cachet;
43+
typedef std::unordered_map<irep_idt, object_listt> object_cachet;
4544
object_cachet object_cache;
4645

4746
forall_goto_program_instructions(i_it, goto_program)
@@ -133,8 +132,7 @@ void invariant_propagationt::add_objects(
133132
const goto_programt &goto_program=f_it->second.body;
134133

135134
// cache the list for the locals to speed things up
136-
typedef std::unordered_map<irep_idt, object_listt, irep_id_hash>
137-
object_cachet;
135+
typedef std::unordered_map<irep_idt, object_listt> object_cachet;
138136
object_cachet object_cache;
139137

140138
forall_goto_program_instructions(i_it, goto_program)

src/analyses/reaching_definitions.h

+3-4
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class sparse_bitvector_analysist
6060
protected:
6161
typedef typename std::map<V, std::size_t> inner_mapt;
6262
std::vector<typename inner_mapt::const_iterator> values;
63-
std::unordered_map<irep_idt, inner_mapt, irep_id_hash> value_map;
63+
std::unordered_map<irep_idt, inner_mapt> value_map;
6464
};
6565

6666
struct reaching_definitiont
@@ -191,15 +191,14 @@ class rd_range_domaint:public ai_domain_baset
191191
#ifdef USE_DSTRING
192192
typedef std::map<irep_idt, values_innert> valuest;
193193
#else
194-
typedef std::unordered_map<irep_idt, values_innert, irep_id_hash> valuest;
194+
typedef std::unordered_map<irep_idt, values_innert> valuest;
195195
#endif
196196
valuest values;
197197

198198
#ifdef USE_DSTRING
199199
typedef std::map<irep_idt, ranges_at_loct> export_cachet;
200200
#else
201-
typedef std::unordered_map<irep_idt, ranges_at_loct, irep_id_hash>
202-
export_cachet;
201+
typedef std::unordered_map<irep_idt, ranges_at_loct> export_cachet;
203202
#endif
204203
mutable export_cachet export_cache;
205204

src/ansi-c/ansi_c_scope.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,7 @@ class ansi_c_scopet
4141
public:
4242
// This maps "scope names" (tag-X, label-X, X) to
4343
// ansi_c_identifiert.
44-
typedef std::unordered_map<irep_idt, ansi_c_identifiert, irep_id_hash>
45-
name_mapt;
44+
typedef std::unordered_map<irep_idt, ansi_c_identifiert> name_mapt;
4645
name_mapt name_map;
4746

4847
std::string prefix;

src/ansi-c/c_typecheck_base.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class c_typecheck_baset:
6969
const irep_idt mode;
7070
symbolt current_symbol;
7171

72-
typedef std::unordered_map<irep_idt, typet, irep_id_hash> id_type_mapt;
72+
typedef std::unordered_map<irep_idt, typet> id_type_mapt;
7373
id_type_mapt parameter_map;
7474

7575
// overload to use language specific syntax
@@ -270,7 +270,7 @@ class c_typecheck_baset:
270270
src.id()==ID_real;
271271
}
272272

273-
typedef std::unordered_map<irep_idt, irep_idt, irep_id_hash> asm_label_mapt;
273+
typedef std::unordered_map<irep_idt, irep_idt> asm_label_mapt;
274274
asm_label_mapt asm_label_map;
275275

276276
void apply_asm_label(const irep_idt &asm_label, symbolt &symbol);

src/ansi-c/c_typecheck_type.cpp

+1-1
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.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -1688,8 +1688,8 @@ std::string expr2ct::convert_symbol(
16881688
dest=src.op0().get_string(ID_identifier);
16891689
else
16901690
{
1691-
std::unordered_map<irep_idt, irep_idt, irep_id_hash>::const_iterator
1692-
entry=shorthands.find(id);
1691+
std::unordered_map<irep_idt, irep_idt>::const_iterator entry =
1692+
shorthands.find(id);
16931693
// we might be called from conversion of a type
16941694
if(entry==shorthands.end())
16951695
{

src/ansi-c/expr2c_class.h

+2-4
Original file line numberDiff line numberDiff line change
@@ -64,10 +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;
70-
std::unordered_map<irep_idt, irep_idt, irep_id_hash> shorthands;
67+
std::unordered_map<irep_idt, std::unordered_set<irep_idt>> ns_collision;
68+
std::unordered_map<irep_idt, irep_idt> shorthands;
7169

7270
unsigned sizeof_nesting;
7371

src/ansi-c/type2name.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ Author: Daniel Kroening, [email protected]
1919
#include <util/pointer_offset_size.h>
2020
#include <util/invariant.h>
2121

22-
typedef std::unordered_map<irep_idt, std::pair<size_t, bool>, irep_id_hash>
23-
symbol_numbert;
22+
typedef std::unordered_map<irep_idt, std::pair<size_t, bool>> symbol_numbert;
2423

2524
static std::string type2name(
2625
const typet &type,

src/cbmc/symex_bmc.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ class symex_bmct: public goto_symext
112112
unsigned max_unwind;
113113
bool max_unwind_is_set;
114114

115-
typedef std::unordered_map<irep_idt, unsigned, irep_id_hash> loop_limitst;
115+
typedef std::unordered_map<irep_idt, unsigned> loop_limitst;
116116
loop_limitst loop_limits;
117117

118118
typedef std::map<unsigned, loop_limitst> thread_loop_limitst;
@@ -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/cpp/cpp_scopes.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class cpp_scopest
6565
}
6666

6767
// mapping from function/class/scope names to their cpp_idt
68-
typedef std::unordered_map<irep_idt, cpp_idt *, irep_id_hash> id_mapt;
68+
typedef std::unordered_map<irep_idt, cpp_idt *> id_mapt;
6969
id_mapt id_map;
7070

7171
cpp_scopet *current_scope_ptr;

src/cpp/expr2cpp.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ class expr2cppt:public expr2ct
4343
const typet &src,
4444
const qualifierst &qualifiers,
4545
const std::string &declarator) override;
46-
47-
typedef std::unordered_set<std::string, string_hash> id_sett;
4846
};
4947

5048
std::string expr2cppt::convert_struct(

src/goto-diff/goto_diff.h

+3-4
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

+2-2
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

+3-6
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,10 +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();
394-
++it)
395-
add_contract_check(*it, i_it->second.body);
391+
for(const auto &contract : summarized)
392+
add_contract_check(contract, i_it->second.body);
396393

397394
// remove skips
398395
remove_skip(i_it->second.body);

src/goto-instrument/count_eloc.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Date: December 2012
2121

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

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

2828
static void collect_eloc(
2929
const goto_modelt &goto_model,

src/goto-instrument/cover_basic_blocks.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ class cover_basic_blocks_javat final : public cover_blocks_baset
125125
// map block number to its location
126126
std::vector<source_locationt> block_locations;
127127
// map java indexes to block indexes
128-
std::unordered_map<irep_idt, std::size_t, irep_id_hash> index_to_block;
128+
std::unordered_map<irep_idt, std::size_t> index_to_block;
129129

130130
public:
131131
explicit cover_basic_blocks_javat(const goto_programt &_goto_program);

src/goto-instrument/dump_c.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ void dump_ct::operator()(std::ostream &os)
8787
copied_symbol_table.add(symbol_pair.second);
8888
}
8989

90-
typedef std::unordered_map<irep_idt, unsigned, irep_id_hash> unique_tagst;
90+
typedef std::unordered_map<irep_idt, unsigned> unique_tagst;
9191
unique_tagst unique_tags;
9292

9393
// add tags to anonymous union/struct/enum,
@@ -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,10 +769,9 @@ 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>
775-
forward_deps, reverse_deps;
772+
std::unordered_set<irep_idt> typedefs_done;
773+
std::unordered_map<irep_idt, std::unordered_set<irep_idt>> forward_deps,
774+
reverse_deps;
776775

777776
for(const auto &td : typedef_map)
778777
if(!td.second.type_decl_str.empty())
@@ -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

0 commit comments

Comments
 (0)