Skip to content

Commit 91430c6

Browse files
committed
Use forall_goto_functions, forall_goto_program_instructions
1 parent 1f4be1e commit 91430c6

13 files changed

+28
-94
lines changed

src/aa-symex/path_search.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -491,23 +491,17 @@ Function: path_searcht::initialize_property_map
491491
void path_searcht::initialize_property_map(
492492
const goto_functionst &goto_functions)
493493
{
494-
for(goto_functionst::function_mapt::const_iterator
495-
it=goto_functions.function_map.begin();
496-
it!=goto_functions.function_map.end();
497-
it++)
494+
forall_goto_functions(it, goto_functions)
498495
if(!it->second.is_inlined())
499496
{
500497
const goto_programt &goto_program=it->second.body;
501498

502-
for(goto_programt::instructionst::const_iterator
503-
it=goto_program.instructions.begin();
504-
it!=goto_program.instructions.end();
505-
it++)
499+
forall_goto_program_instructions(i_it, goto_program)
506500
{
507-
if(!it->is_assert())
501+
if(!i_it->is_assert())
508502
continue;
509503

510-
const locationt &location=it->location;
504+
const locationt &location=i_it->location;
511505

512506
irep_idt property_name=location.get_property_id();
513507

src/analyses/flow_insensitive_analysis.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,7 @@ void flow_insensitive_analysis_baset::output(
132132
const goto_functionst &goto_functions,
133133
std::ostream &out)
134134
{
135-
for(goto_functionst::function_mapt::const_iterator
136-
f_it=goto_functions.function_map.begin();
137-
f_it!=goto_functions.function_map.end();
138-
f_it++)
135+
forall_goto_functions(f_it, goto_functions)
139136
{
140137
out << "////" << std::endl;
141138
out << "//// Function: " << f_it->first << std::endl;
@@ -547,10 +544,7 @@ void flow_insensitive_analysis_baset::fixedpoint(
547544
{
548545
// do each function at least once
549546

550-
for(goto_functionst::function_mapt::const_iterator
551-
it=goto_functions.function_map.begin();
552-
it!=goto_functions.function_map.end();
553-
it++)
547+
forall_goto_functions(it, goto_functions)
554548
if(functions_done.find(it->first)==
555549
functions_done.end())
556550
{

src/analyses/goto_check.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1729,10 +1729,7 @@ void goto_checkt::goto_check(goto_functiont &goto_function)
17291729
}
17301730
}
17311731

1732-
for(goto_programt::instructionst::iterator
1733-
i_it=new_code.instructions.begin();
1734-
i_it!=new_code.instructions.end();
1735-
i_it++)
1732+
Forall_goto_program_instructions(i_it, new_code)
17361733
{
17371734
if(i_it->source_location.is_nil())
17381735
{
@@ -1805,10 +1802,7 @@ void goto_check(
18051802
{
18061803
goto_checkt goto_check(ns, options);
18071804

1808-
for(goto_functionst::function_mapt::iterator
1809-
it=goto_functions.function_map.begin();
1810-
it!=goto_functions.function_map.end();
1811-
it++)
1805+
Forall_goto_functions(it, goto_functions)
18121806
{
18131807
goto_check.goto_check(it->second);
18141808
}
@@ -1833,10 +1827,7 @@ void goto_check(
18331827
const namespacet ns(goto_model.symbol_table);
18341828
goto_checkt goto_check(ns, options);
18351829

1836-
for(goto_functionst::function_mapt::iterator
1837-
it=goto_model.goto_functions.function_map.begin();
1838-
it!=goto_model.goto_functions.function_map.end();
1839-
it++)
1830+
Forall_goto_functions(it, goto_model.goto_functions)
18401831
{
18411832
goto_check.goto_check(it->second);
18421833
}

src/analyses/static_analysis.cpp

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,7 @@ void static_analysis_baset::output(
135135
const goto_functionst &goto_functions,
136136
std::ostream &out) const
137137
{
138-
for(goto_functionst::function_mapt::const_iterator
139-
f_it=goto_functions.function_map.begin();
140-
f_it!=goto_functions.function_map.end();
141-
f_it++)
138+
forall_goto_functions(f_it, goto_functions)
142139
{
143140
if(f_it->second.body_available())
144141
{
@@ -198,10 +195,7 @@ Function: static_analysis_baset::generate_states
198195
void static_analysis_baset::generate_states(
199196
const goto_functionst &goto_functions)
200197
{
201-
for(goto_functionst::function_mapt::const_iterator
202-
f_it=goto_functions.function_map.begin();
203-
f_it!=goto_functions.function_map.end();
204-
f_it++)
198+
forall_goto_functions(f_it, goto_functions)
205199
generate_states(f_it->second.body);
206200
}
207201

@@ -239,10 +233,7 @@ Function: static_analysis_baset::update
239233
void static_analysis_baset::update(
240234
const goto_functionst &goto_functions)
241235
{
242-
for(goto_functionst::function_mapt::const_iterator
243-
f_it=goto_functions.function_map.begin();
244-
f_it!=goto_functions.function_map.end();
245-
f_it++)
236+
forall_goto_functions(f_it, goto_functions)
246237
update(f_it->second.body);
247238
}
248239

src/goto-instrument/dot.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,14 +297,9 @@ void dott::output(std::ostream &out)
297297

298298
std::list<exprt> clusters;
299299

300-
for(goto_functionst::function_mapt::const_iterator
301-
it=goto_functions.function_map.begin();
302-
it!=goto_functions.function_map.end();
303-
it++)
304-
{
300+
forall_goto_functions(it, goto_functions)
305301
if(it->second.body_available())
306302
write_dot_subgraph(out, id2string(it->first), it->second.body);
307-
}
308303

309304
do_dot_function_calls(out);
310305

src/goto-instrument/unwind.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,8 +385,7 @@ void goto_unwindt::unwind(
385385
{
386386
assert(k>=-1);
387387

388-
for(goto_programt::const_targett i_it=goto_program.instructions.begin();
389-
i_it!=goto_program.instructions.end(); i_it++)
388+
forall_goto_program_instructions(i_it, goto_program)
390389
{
391390
if(!i_it->is_backwards_goto())
392391
continue;

src/goto-programs/goto_convert_functions.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,7 @@ Function: goto_convert_functionst::hide
119119

120120
bool goto_convert_functionst::hide(const goto_programt &goto_program)
121121
{
122-
for(goto_programt::instructionst::const_iterator
123-
i_it=goto_program.instructions.begin();
124-
i_it!=goto_program.instructions.end();
125-
i_it++)
122+
forall_goto_program_instructions(i_it, goto_program)
126123
{
127124
for(const auto &label : i_it->labels)
128125
if(label=="__CPROVER_HIDE")

src/goto-programs/goto_program_irep.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ void convert( const goto_programt &program, irept &irep )
109109
{
110110
irep.id("goto-program");
111111
irep.get_sub().reserve(program.instructions.size());
112-
for (goto_programt::instructionst::const_iterator it=
113-
program.instructions.begin();
114-
it!=program.instructions.end();
115-
it++)
112+
forall_goto_program_instructions(it, program)
116113
{
117114
irep.get_sub().push_back(irept());
118115
convert(*it, irep.get_sub().back());

src/goto-programs/loop_ids.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,7 @@ void show_loop_ids(
5454
{
5555
case ui_message_handlert::PLAIN:
5656
{
57-
for(goto_programt::instructionst::const_iterator
58-
it=goto_program.instructions.begin();
59-
it!=goto_program.instructions.end(); it++)
57+
forall_goto_program_instructions(it, goto_program)
6058
{
6159
if(it->is_backwards_goto())
6260
{
@@ -73,9 +71,7 @@ void show_loop_ids(
7371
}
7472
case ui_message_handlert::XML_UI:
7573
{
76-
for(goto_programt::instructionst::const_iterator
77-
it=goto_program.instructions.begin();
78-
it!=goto_program.instructions.end(); it++)
74+
forall_goto_program_instructions(it, goto_program)
7975
{
8076
if(it->is_backwards_goto())
8177
{
@@ -103,9 +99,7 @@ void show_loop_ids_json(
10399
{
104100
assert(ui==ui_message_handlert::JSON_UI); //use function above
105101

106-
for(goto_programt::instructionst::const_iterator
107-
it=goto_program.instructions.begin();
108-
it!=goto_program.instructions.end(); it++)
102+
forall_goto_program_instructions(it, goto_program)
109103
{
110104
if(it->is_backwards_goto())
111105
{

src/goto-programs/property_checker.cpp

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,30 +66,24 @@ Function: property_checkert::initialize_property_map
6666
void property_checkert::initialize_property_map(
6767
const goto_functionst &goto_functions)
6868
{
69-
for(goto_functionst::function_mapt::const_iterator
70-
it=goto_functions.function_map.begin();
71-
it!=goto_functions.function_map.end();
72-
it++)
69+
forall_goto_functions(it, goto_functions)
7370
if(!it->second.is_inlined() ||
7471
it->first==goto_functions.entry_point())
7572
{
7673
const goto_programt &goto_program=it->second.body;
7774

78-
for(goto_programt::instructionst::const_iterator
79-
it=goto_program.instructions.begin();
80-
it!=goto_program.instructions.end();
81-
it++)
75+
forall_goto_program_instructions(i_it, goto_program)
8276
{
83-
if(!it->is_assert())
77+
if(!i_it->is_assert())
8478
continue;
8579

86-
const source_locationt &source_location=it->source_location;
80+
const source_locationt &source_location=i_it->source_location;
8781

8882
irep_idt property_id=source_location.get_property_id();
8983

9084
property_statust &property_status=property_map[property_id];
9185
property_status.result=UNKNOWN;
92-
property_status.location=it;
86+
property_status.location=i_it;
9387
}
9488
}
9589
}

src/goto-programs/remove_function_pointers.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,7 @@ remove_function_pointerst::remove_function_pointerst(
106106
compute_address_taken_functions(goto_functions, address_taken);
107107

108108
// build type map
109-
for(goto_functionst::function_mapt::const_iterator f_it=
110-
goto_functions.function_map.begin();
111-
f_it!=goto_functions.function_map.end();
112-
f_it++)
109+
forall_goto_functions(f_it, goto_functions)
113110
type_map[f_it->first]=f_it->second.type;
114111
}
115112

src/goto-programs/set_properties.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,7 @@ void set_properties(
172172

173173
property_set.insert(properties.begin(), properties.end());
174174

175-
for(goto_functionst::function_mapt::iterator
176-
it=goto_functions.function_map.begin();
177-
it!=goto_functions.function_map.end();
178-
it++)
175+
Forall_goto_functions(it, goto_functions)
179176
if(!it->second.is_inlined())
180177
set_properties(it->second.body, property_set);
181178

src/goto-programs/show_goto_functions.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,7 @@ void show_goto_functions(
4343
{
4444
//This only prints the list of functions
4545
xmlt xml_functions("functions");
46-
for(goto_functionst::function_mapt::const_iterator
47-
it=goto_functions.function_map.begin();
48-
it!=goto_functions.function_map.end();
49-
it++)
46+
forall_goto_functions(it, goto_functions)
5047
{
5148
xmlt &xml_function=xml_functions.new_element("function");
5249
xml_function.set_attribute("name", id2string(it->first));
@@ -60,10 +57,7 @@ void show_goto_functions(
6057
{
6158
//This only prints the list of functions
6259
json_arrayt json_functions;
63-
for(goto_functionst::function_mapt::const_iterator
64-
it=goto_functions.function_map.begin();
65-
it!=goto_functions.function_map.end();
66-
it++)
60+
forall_goto_functions(it, goto_functions)
6761
{
6862
json_objectt &json_function=
6963
json_functions.push_back(jsont()).make_object();

0 commit comments

Comments
 (0)