Skip to content

Commit cef68e6

Browse files
Move all the various id_sett typedefs into irep.h
Call them unordered_id_sett to reflect the fact that these are unordered sets
1 parent 00b9bf6 commit cef68e6

15 files changed

+60
-69
lines changed

src/analyses/dirty.h

+2-3
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 unordered_id_sett &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+
unordered_id_sett dirty;
101100

102101
void find_dirty(const exprt &expr);
103102
void find_dirty_address_of(const exprt &expr);

src/goto-instrument/code_contracts.cpp

+3-4
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+
unordered_id_sett 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(unordered_id_sett::const_iterator it = summarized.begin();
392+
it != summarized.end();
394393
++it)
395394
add_contract_check(*it, i_it->second.body);
396395

src/goto-instrument/dump_c.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -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+
unordered_id_sett typedefs_done;
773+
std::unordered_map<irep_idt, unordered_id_sett, irep_id_hash> 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+
unordered_id_sett &r_deps = r_it->second;
808+
for(unordered_id_sett::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+
unordered_id_sett &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);

src/goto-instrument/goto_program2code.h

+22-23
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 unordered_id_sett &_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 unordered_id_sett &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+
unordered_id_sett 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+
unordered_id_sett local_static_set;
96+
unordered_id_sett type_names_set;
97+
unordered_id_sett const_removed;
9998

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

src/goto-programs/link_goto_model.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -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+
unordered_id_sett weak_symbols;
163162

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

src/java_bytecode/java_bytecode_language.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ const select_pointer_typet &
819819
/// \return Populates `methods` with the complete list of lazy methods that are
820820
/// available to convert (those which are valid parameters for
821821
/// `convert_lazy_method`)
822-
void java_bytecode_languaget::methods_provided(id_sett &methods) const
822+
void java_bytecode_languaget::methods_provided(unordered_id_sett &methods) const
823823
{
824824
// Add all string solver methods to map
825825
string_preprocess.get_all_function_names(methods);

src/java_bytecode/java_bytecode_language.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ class java_bytecode_languaget:public languaget
135135
std::set<std::string> extensions() const override;
136136

137137
void modules_provided(std::set<std::string> &modules) override;
138-
virtual void methods_provided(id_sett &methods) const override;
138+
virtual void methods_provided(unordered_id_sett &methods) const override;
139139
virtual void convert_lazy_method(
140140
const irep_idt &function_id,
141141
symbol_table_baset &symbol_table) override;

src/java_bytecode/java_string_library_preprocess.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1827,7 +1827,7 @@ void add_keys_to_container(const TMap &map, TContainer &container)
18271827
}
18281828

18291829
void java_string_library_preprocesst::get_all_function_names(
1830-
id_sett &methods) const
1830+
unordered_id_sett &methods) const
18311831
{
18321832
for(const id_mapt *map : id_maps)
18331833
add_keys_to_container(*map, methods);

src/java_bytecode/java_string_library_preprocess.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ Date: March 2017
3131
// Arbitrary limit of 10 arguments for the number of arguments to String.format
3232
#define MAX_FORMAT_ARGS 10
3333

34-
typedef std::unordered_set<irep_idt, irep_id_hash> id_sett;
35-
3634
class java_string_library_preprocesst:public messaget
3735
{
3836
public:
@@ -48,7 +46,7 @@ class java_string_library_preprocesst:public messaget
4846
void initialize_refined_string_type();
4947

5048
bool implements_function(const irep_idt &function_id) const;
51-
void get_all_function_names(id_sett &methods) const;
49+
void get_all_function_names(unordered_id_sett &methods) const;
5250

5351
exprt
5452
code_for_function(const symbolt &symbol, symbol_table_baset &symbol_table);

src/langapi/language.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@ Author: Daniel Kroening, [email protected]
2323

2424
#include <goto-programs/system_library_symbols.h>
2525

26-
typedef std::unordered_set<irep_idt, irep_id_hash> id_sett;
27-
2826
class symbol_tablet;
2927
class symbol_table_baset;
3028
class exprt;
@@ -79,7 +77,7 @@ class languaget:public messaget
7977

8078
// add lazy functions provided to set
8179

82-
virtual void methods_provided(id_sett &methods) const
80+
virtual void methods_provided(unordered_id_sett &methods) const
8381
{ }
8482

8583
// populate a lazy method

src/langapi/language_file.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ bool language_filest::typecheck(symbol_tablet &symbol_table)
144144
// register lazy methods.
145145
// TODO: learn about modules and generalise this
146146
// to module-providing languages if required.
147-
id_sett lazy_method_ids;
147+
unordered_id_sett lazy_method_ids;
148148
file.second.language->methods_provided(lazy_method_ids);
149149
for(const auto &id : lazy_method_ids)
150150
lazy_method_map[id]=&file.second;

src/langapi/language_file.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class language_filest:public messaget
8383
{
8484
// Clear relevant entries from lazy_method_map
8585
language_filet *language_file = &file_map.at(filename);
86-
id_sett files_methods;
86+
unordered_id_sett files_methods;
8787
for(const std::pair<irep_idt, language_filet *> &method : lazy_method_map)
8888
{
8989
if(method.second == language_file)

src/linking/linking.cpp

+8-11
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ bool linkingt::needs_renaming_type(
11621162
return true; // different
11631163
}
11641164

1165-
void linkingt::do_type_dependencies(id_sett &needs_to_be_renamed)
1165+
void linkingt::do_type_dependencies(unordered_id_sett &needs_to_be_renamed)
11661166
{
11671167
// Any type that uses a symbol that will be renamed also
11681168
// needs to be renamed, and so on, until saturation.
@@ -1186,9 +1186,8 @@ void linkingt::do_type_dependencies(id_sett &needs_to_be_renamed)
11861186

11871187
std::stack<irep_idt> queue;
11881188

1189-
for(id_sett::const_iterator
1190-
d_it=needs_to_be_renamed.begin();
1191-
d_it!=needs_to_be_renamed.end();
1189+
for(unordered_id_sett::const_iterator d_it = needs_to_be_renamed.begin();
1190+
d_it != needs_to_be_renamed.end();
11921191
d_it++)
11931192
queue.push(*d_it);
11941193

@@ -1197,11 +1196,9 @@ void linkingt::do_type_dependencies(id_sett &needs_to_be_renamed)
11971196
irep_idt id=queue.top();
11981197
queue.pop();
11991198

1200-
const id_sett &u=used_by[id];
1199+
const unordered_id_sett &u = used_by[id];
12011200

1202-
for(id_sett::const_iterator
1203-
d_it=u.begin();
1204-
d_it!=u.end();
1201+
for(unordered_id_sett::const_iterator d_it = u.begin(); d_it != u.end();
12051202
d_it++)
12061203
if(needs_to_be_renamed.insert(*d_it).second)
12071204
{
@@ -1214,7 +1211,7 @@ void linkingt::do_type_dependencies(id_sett &needs_to_be_renamed)
12141211
}
12151212
}
12161213

1217-
void linkingt::rename_symbols(const id_sett &needs_to_be_renamed)
1214+
void linkingt::rename_symbols(const unordered_id_sett &needs_to_be_renamed)
12181215
{
12191216
namespacet src_ns(src_symbol_table);
12201217

@@ -1258,7 +1255,7 @@ void linkingt::copy_symbols()
12581255
}
12591256

12601257
// Move over all the non-colliding ones
1261-
id_sett collisions;
1258+
unordered_id_sett collisions;
12621259

12631260
for(const auto &named_symbol : src_symbols)
12641261
{
@@ -1313,7 +1310,7 @@ void linkingt::typecheck()
13131310

13141311
// PHASE 1: identify symbols to be renamed
13151312

1316-
id_sett needs_to_be_renamed;
1313+
unordered_id_sett needs_to_be_renamed;
13171314

13181315
for(const auto &symbol_pair : src_symbol_table.symbols)
13191316
{

src/linking/linking_class.h

+7-8
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ class linkingt:public typecheckt
3838
replace_symbolt object_type_updates;
3939

4040
protected:
41-
typedef std::unordered_set<irep_idt, irep_id_hash> id_sett;
42-
4341
bool needs_renaming_type(
4442
const symbolt &old_symbol,
4543
const symbolt &new_symbol);
@@ -58,9 +56,9 @@ class linkingt:public typecheckt
5856
return needs_renaming_non_type(old_symbol, new_symbol);
5957
}
6058

61-
void do_type_dependencies(id_sett &);
59+
void do_type_dependencies(unordered_id_sett &);
6260

63-
void rename_symbols(const id_sett &needs_to_be_renamed);
61+
void rename_symbols(const unordered_id_sett &needs_to_be_renamed);
6462
void copy_symbols();
6563

6664
void duplicate_non_type_symbol(
@@ -94,8 +92,8 @@ class linkingt:public typecheckt
9492
const symbolt &old_symbol;
9593
const symbolt &new_symbol;
9694
bool set_to_new;
97-
id_sett o_symbols;
98-
id_sett n_symbols;
95+
unordered_id_sett o_symbols;
96+
unordered_id_sett n_symbols;
9997
};
10098

10199
bool adjust_object_type_rec(
@@ -173,12 +171,13 @@ class linkingt:public typecheckt
173171
namespacet ns;
174172

175173
// X -> Y iff Y uses X for new symbol type IDs X and Y
176-
typedef std::unordered_map<irep_idt, id_sett, irep_id_hash> used_byt;
174+
typedef std::unordered_map<irep_idt, unordered_id_sett, irep_id_hash>
175+
used_byt;
177176

178177
irep_idt rename(irep_idt);
179178

180179
// the new IDs created by renaming
181-
id_sett renamed_ids;
180+
unordered_id_sett renamed_ids;
182181
};
183182

184183
#endif // CPROVER_LINKING_LINKING_CLASS_H

src/util/irep.h

+3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Author: Daniel Kroening, [email protected]
1414
#include <string>
1515
#include <cassert>
1616
#include <iosfwd>
17+
#include <unordered_set>
1718

1819
#include "irep_ids.h"
1920

@@ -44,6 +45,8 @@ typedef std::string irep_namet;
4445
typedef string_hash irep_id_hash;
4546
#endif
4647

48+
typedef std::unordered_set<irep_idt, irep_id_hash> unordered_id_sett;
49+
4750
inline const std::string &id2string(const irep_idt &d)
4851
{
4952
#ifdef USE_DSTRING

0 commit comments

Comments
 (0)