Skip to content

Commit cf1b4b4

Browse files
author
Daniel Kroening
authored
Merge pull request #859 from reuk/goto-prog-style
Improve style in goto_program_template.h
2 parents 832eb93 + 3ee1918 commit cf1b4b4

13 files changed

+84
-191
lines changed

src/analyses/ai.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -412,11 +412,7 @@ bool ai_baset::visit(
412412

413413
statet &current=get_state(l);
414414

415-
goto_programt::const_targetst successors;
416-
417-
goto_program.get_successors(l, successors);
418-
419-
for(const auto &to_l : successors)
415+
for(const auto &to_l : goto_program.get_successors(l))
420416
{
421417
if(to_l==goto_program.instructions.end())
422418
continue;

src/analyses/flow_insensitive_analysis.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -256,16 +256,13 @@ bool flow_insensitive_analysis_baset::visit(
256256
l->location_number << std::endl;
257257
#endif
258258

259-
goto_programt::const_targetst successors;
260-
goto_program.get_successors(l, successors);
261-
262259
seen_locations.insert(l);
263260
if(statistics.find(l)==statistics.end())
264261
statistics[l]=1;
265262
else
266263
statistics[l]++;
267264

268-
for(const auto &to_l : successors)
265+
for(const auto &to_l : goto_program.get_successors(l))
269266
{
270267
if(to_l==goto_program.instructions.end())
271268
continue;

src/analyses/static_analysis.cpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,7 @@ bool static_analysis_baset::visit(
356356

357357
current.seen=true;
358358

359-
goto_programt::const_targetst successors;
360-
361-
goto_program.get_successors(l, successors);
362-
363-
for(const auto &to_l : successors)
359+
for(const auto &to_l : goto_program.get_successors(l))
364360
{
365361
if(to_l==goto_program.instructions.end())
366362
continue;

src/cegis/cegis-util/program_helper.cpp

+12-7
Original file line numberDiff line numberDiff line change
@@ -350,18 +350,23 @@ goto_programt::targett insert_preserving_source_location(
350350
goto_programt::targett insert_after_preserving_source_location(
351351
goto_programt &body, goto_programt::targett pos)
352352
{
353-
const auto op=std::bind1st(std::mem_fun(&goto_programt::insert_after), &body);
354-
return insert_preserving_source_location(pos, op);
353+
return insert_preserving_source_location(
354+
pos,
355+
[&](goto_programt::const_targett target)
356+
{
357+
return body.insert_after(target);
358+
});
355359
}
356360

357361
goto_programt::targett insert_before_preserving_source_location(
358362
goto_programt &body, goto_programt::targett pos)
359363
{
360-
typedef goto_programt::targett (goto_programt::*ftype)(
361-
goto_programt::targett);
362-
const auto op=std::bind1st(
363-
std::mem_fun(static_cast<ftype>(&goto_programt::insert_before)), &body);
364-
return insert_preserving_source_location(pos, op);
364+
return insert_preserving_source_location(
365+
pos,
366+
[&](goto_programt::const_targett target)
367+
{
368+
return body.insert_before(target);
369+
});
365370
}
366371

367372
void assign_in_cprover_init(goto_functionst &gf, symbolt &symbol,

src/goto-instrument/accelerate/all_paths_enumerator.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,7 @@ int all_paths_enumeratort::backtrack(patht &path)
6969
path.pop_back();
7070

7171
path_nodet &parent=path.back();
72-
goto_programt::targetst succs;
73-
goto_program.get_successors(parent.loc, succs);
72+
const auto succs=goto_program.get_successors(parent.loc);
7473

7574
unsigned int ret=0;
7675

@@ -119,12 +118,9 @@ void all_paths_enumeratort::extend_path(
119118
int succ)
120119
{
121120
goto_programt::targett next;
122-
goto_programt::targetst succs;
123121
exprt guard=true_exprt();
124122

125-
goto_program.get_successors(t, succs);
126-
127-
for(const auto &s : succs)
123+
for(const auto &s : goto_program.get_successors(t))
128124
{
129125
if(succ==0)
130126
{

src/goto-instrument/accelerate/disjunctive_polynomial_acceleration.cpp

+4-9
Original file line numberDiff line numberDiff line change
@@ -757,23 +757,19 @@ void disjunctive_polynomial_accelerationt::find_distinguishing_points()
757757
it!=loop.end();
758758
++it)
759759
{
760-
goto_programt::targetst succs;
761-
762-
goto_program.get_successors(*it, succs);
760+
const auto succs=goto_program.get_successors(*it);
763761

764762
if(succs.size() > 1)
765763
{
766764
// This location has multiple successors -- each successor is a
767765
// distinguishing point.
768-
for(goto_programt::targetst::iterator jt=succs.begin();
769-
jt!=succs.end();
770-
++jt)
766+
for(const auto &jt : succs)
771767
{
772768
symbolt distinguisher_sym =
773769
utils.fresh_symbol("polynomial::distinguisher", bool_typet());
774770
symbol_exprt distinguisher=distinguisher_sym.symbol_expr();
775771

776-
distinguishing_points[*jt]=distinguisher;
772+
distinguishing_points[jt]=distinguisher;
777773
distinguishers.push_back(distinguisher);
778774
}
779775
}
@@ -788,9 +784,8 @@ void disjunctive_polynomial_accelerationt::build_path(
788784
do
789785
{
790786
goto_programt::targett next;
791-
goto_programt::targetst succs;
792787

793-
goto_program.get_successors(t, succs);
788+
const auto succs=goto_program.get_successors(t);
794789

795790
// We should have a looping path, so we should never hit a location
796791
// with no successors.

src/goto-instrument/accelerate/sat_path_enumerator.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ void sat_path_enumeratort::find_distinguishing_points()
109109
it!=loop.end();
110110
++it)
111111
{
112-
goto_programt::targetst succs;
113-
114-
goto_program.get_successors(*it, succs);
112+
const auto succs=goto_program.get_successors(*it);
115113

116114
if(succs.size()>1)
117115
{
@@ -139,9 +137,7 @@ void sat_path_enumeratort::build_path(
139137
do
140138
{
141139
goto_programt::targett next;
142-
goto_programt::targetst succs;
143-
144-
goto_program.get_successors(t, succs);
140+
const auto succs=goto_program.get_successors(t);
145141

146142
// We should have a looping path, so we should never hit a location
147143
// with no successors.

src/goto-instrument/accelerate/trace_automaton.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,7 @@ void trace_automatont::build_alphabet(goto_programt &program)
3838
{
3939
Forall_goto_program_instructions(it, program)
4040
{
41-
goto_programt::targetst succs;
42-
43-
program.get_successors(it, succs);
44-
41+
const auto succs=program.get_successors(it);
4542
if(succs.size()>1)
4643
{
4744
alphabet.insert(succs.begin(), succs.end());

src/goto-instrument/call_sequences.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,11 @@ void show_call_sequences(
6262
continue; // abort search
6363
}
6464

65-
// get successors
66-
goto_programt::const_targetst s;
67-
goto_program.get_successors(t, s);
68-
69-
// add to stack
70-
for(goto_programt::const_targetst::const_iterator
71-
it=s.begin(); it!=s.end(); it++)
72-
stack.push(*it);
65+
// get successors and add to stack
66+
for(const auto &it : goto_program.get_successors(t))
67+
{
68+
stack.push(it);
69+
}
7370
}
7471
}
7572

src/goto-instrument/dot.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,7 @@ void dott::write_dot_subgraph(
217217
write_edge(out, *it, **frit, flabel);
218218

219219
seen.insert(it);
220-
goto_programt::const_targetst temp;
221-
goto_program.get_successors(it, temp);
220+
const auto temp=goto_program.get_successors(it);
222221
worklist.insert(worklist.end(), temp.begin(), temp.end());
223222
}
224223
}

src/goto-instrument/wmm/goto2graph.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1541,7 +1541,7 @@ bool instrumentert::is_cfg_spurious(const event_grapht::critical_cyclet &cyc)
15411541
map.insert(p);
15421542

15431543
goto_functionst this_interleaving;
1544-
this_interleaving.function_map=map;
1544+
this_interleaving.function_map=std::move(map);
15451545
optionst no_option;
15461546
null_message_handlert no_message;
15471547

0 commit comments

Comments
 (0)