Skip to content

Improve style in goto_program_template.h #859

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 3, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions src/analyses/ai.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,11 +412,7 @@ bool ai_baset::visit(

statet &current=get_state(l);

goto_programt::const_targetst successors;

goto_program.get_successors(l, successors);

for(const auto &to_l : successors)
for(const auto &to_l : goto_program.get_successors(l))
{
if(to_l==goto_program.instructions.end())
continue;
Expand Down
5 changes: 1 addition & 4 deletions src/analyses/flow_insensitive_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,13 @@ bool flow_insensitive_analysis_baset::visit(
l->location_number << std::endl;
#endif

goto_programt::const_targetst successors;
goto_program.get_successors(l, successors);

seen_locations.insert(l);
if(statistics.find(l)==statistics.end())
statistics[l]=1;
else
statistics[l]++;

for(const auto &to_l : successors)
for(const auto &to_l : goto_program.get_successors(l))
{
if(to_l==goto_program.instructions.end())
continue;
Expand Down
6 changes: 1 addition & 5 deletions src/analyses/static_analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -356,11 +356,7 @@ bool static_analysis_baset::visit(

current.seen=true;

goto_programt::const_targetst successors;

goto_program.get_successors(l, successors);

for(const auto &to_l : successors)
for(const auto &to_l : goto_program.get_successors(l))
{
if(to_l==goto_program.instructions.end())
continue;
Expand Down
19 changes: 12 additions & 7 deletions src/cegis/cegis-util/program_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,18 +350,23 @@ goto_programt::targett insert_preserving_source_location(
goto_programt::targett insert_after_preserving_source_location(
goto_programt &body, goto_programt::targett pos)
{
const auto op=std::bind1st(std::mem_fun(&goto_programt::insert_after), &body);
return insert_preserving_source_location(pos, op);
return insert_preserving_source_location(
pos,
[&](goto_programt::const_targett target)
{
return body.insert_after(target);
});
}

goto_programt::targett insert_before_preserving_source_location(
goto_programt &body, goto_programt::targett pos)
{
typedef goto_programt::targett (goto_programt::*ftype)(
goto_programt::targett);
const auto op=std::bind1st(
std::mem_fun(static_cast<ftype>(&goto_programt::insert_before)), &body);
return insert_preserving_source_location(pos, op);
return insert_preserving_source_location(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was broken due to insert_before changing to take a const_targett instead of a targett. I could just fix the typedef, but Meyers recommends in 'Effective Modern C++' that we prefer lambdas over std::bind, so I've made that change too.

pos,
[&](goto_programt::const_targett target)
{
return body.insert_before(target);
});
}

void assign_in_cprover_init(goto_functionst &gf, symbolt &symbol,
Expand Down
8 changes: 2 additions & 6 deletions src/goto-instrument/accelerate/all_paths_enumerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@ int all_paths_enumeratort::backtrack(patht &path)
path.pop_back();

path_nodet &parent=path.back();
goto_programt::targetst succs;
goto_program.get_successors(parent.loc, succs);
const auto succs=goto_program.get_successors(parent.loc);

unsigned int ret=0;

Expand Down Expand Up @@ -119,12 +118,9 @@ void all_paths_enumeratort::extend_path(
int succ)
{
goto_programt::targett next;
goto_programt::targetst succs;
exprt guard=true_exprt();

goto_program.get_successors(t, succs);

for(const auto &s : succs)
for(const auto &s : goto_program.get_successors(t))
{
if(succ==0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -757,23 +757,19 @@ void disjunctive_polynomial_accelerationt::find_distinguishing_points()
it!=loop.end();
++it)
{
goto_programt::targetst succs;

goto_program.get_successors(*it, succs);
const auto succs=goto_program.get_successors(*it);

if(succs.size() > 1)
{
// This location has multiple successors -- each successor is a
// distinguishing point.
for(goto_programt::targetst::iterator jt=succs.begin();
jt!=succs.end();
++jt)
for(const auto &jt : succs)
{
symbolt distinguisher_sym =
utils.fresh_symbol("polynomial::distinguisher", bool_typet());
symbol_exprt distinguisher=distinguisher_sym.symbol_expr();

distinguishing_points[*jt]=distinguisher;
distinguishing_points[jt]=distinguisher;
distinguishers.push_back(distinguisher);
}
}
Expand All @@ -788,9 +784,8 @@ void disjunctive_polynomial_accelerationt::build_path(
do
{
goto_programt::targett next;
goto_programt::targetst succs;

goto_program.get_successors(t, succs);
const auto succs=goto_program.get_successors(t);

// We should have a looping path, so we should never hit a location
// with no successors.
Expand Down
8 changes: 2 additions & 6 deletions src/goto-instrument/accelerate/sat_path_enumerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ void sat_path_enumeratort::find_distinguishing_points()
it!=loop.end();
++it)
{
goto_programt::targetst succs;

goto_program.get_successors(*it, succs);
const auto succs=goto_program.get_successors(*it);

if(succs.size()>1)
{
Expand Down Expand Up @@ -139,9 +137,7 @@ void sat_path_enumeratort::build_path(
do
{
goto_programt::targett next;
goto_programt::targetst succs;

goto_program.get_successors(t, succs);
const auto succs=goto_program.get_successors(t);

// We should have a looping path, so we should never hit a location
// with no successors.
Expand Down
5 changes: 1 addition & 4 deletions src/goto-instrument/accelerate/trace_automaton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,7 @@ void trace_automatont::build_alphabet(goto_programt &program)
{
Forall_goto_program_instructions(it, program)
{
goto_programt::targetst succs;

program.get_successors(it, succs);

const auto succs=program.get_successors(it);
if(succs.size()>1)
{
alphabet.insert(succs.begin(), succs.end());
Expand Down
13 changes: 5 additions & 8 deletions src/goto-instrument/call_sequences.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,11 @@ void show_call_sequences(
continue; // abort search
}

// get successors
goto_programt::const_targetst s;
goto_program.get_successors(t, s);

// add to stack
for(goto_programt::const_targetst::const_iterator
it=s.begin(); it!=s.end(); it++)
stack.push(*it);
// get successors and add to stack
for(const auto &it : goto_program.get_successors(t))
{
stack.push(it);
}
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/goto-instrument/dot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,7 @@ void dott::write_dot_subgraph(
write_edge(out, *it, **frit, flabel);

seen.insert(it);
goto_programt::const_targetst temp;
goto_program.get_successors(it, temp);
const auto temp=goto_program.get_successors(it);
worklist.insert(worklist.end(), temp.begin(), temp.end());
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/goto-instrument/wmm/goto2graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1541,7 +1541,7 @@ bool instrumentert::is_cfg_spurious(const event_grapht::critical_cyclet &cyc)
map.insert(p);

goto_functionst this_interleaving;
this_interleaving.function_map=map;
this_interleaving.function_map=std::move(map);
optionst no_option;
null_message_handlert no_message;

Expand Down
Loading