本文整理汇总了C++中goto_programt::compute_incoming_edges方法的典型用法代码示例。如果您正苦于以下问题:C++ goto_programt::compute_incoming_edges方法的具体用法?C++ goto_programt::compute_incoming_edges怎么用?C++ goto_programt::compute_incoming_edges使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类goto_programt
的用法示例。
在下文中一共展示了goto_programt::compute_incoming_edges方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: transform
void loop_transformt::transform(goto_programt &goto_program)
{
goto_program.compute_incoming_edges();
// pass 1: simple stuff
Forall_goto_program_instructions(it, goto_program)
if(it->is_backwards_goto())
{
assert(it->targets.size()==1);
goto_programt::targett begin = it->targets.front();
goto_programt::targett end = it;
split_multi_head(goto_program, begin, end);
transform_do_while(goto_program, begin, end);
move_returns(goto_program, begin, end);
}
// pass 2: loop simulation
Forall_goto_program_instructions(it, goto_program)
if(it->is_backwards_goto())
{
goto_programt::targett begin = it->targets.front();
goto_programt::targett end = it;
std::set<goto_programt::targett> entries;
std::set<goto_programt::targett> exits;
analyze(goto_program, begin, end, entries, exits);
transform(goto_program, begin, end, entries, exits);
it=end;
}
goto_program.update();
#if 1
// Another run for debugging
forall_goto_program_instructions(it, goto_program)
if(it->is_backwards_goto())
{
goto_programt::const_targett begin = it->targets.front();
goto_programt::const_targett end = it;
run_checks(goto_program, begin, end);
}
#endif
}
示例2: remove_skip
void remove_skip(goto_programt &goto_program)
{
typedef std::map<goto_programt::targett, goto_programt::targett> new_targetst;
new_targetst new_targets;
// remove skip statements
for(goto_programt::instructionst::iterator
it=goto_program.instructions.begin();
it!=goto_program.instructions.end();)
{
goto_programt::targett old_target=it;
// for collecting labels
std::list<irep_idt> labels;
while(is_skip(it))
{
// don't remove the last skip statement,
// it could be a target
if(it==--goto_program.instructions.end())
break;
// save labels
labels.splice(labels.end(), it->labels);
it++;
}
goto_programt::targett new_target=it;
// save labels
it->labels.splice(it->labels.begin(), labels);
if(new_target!=old_target)
{
while(new_target!=old_target)
{
// remember the old targets
new_targets[old_target]=new_target;
old_target=goto_program.instructions.erase(old_target);
}
}
else
it++;
}
// adjust gotos
Forall_goto_program_instructions(i_it, goto_program)
if(i_it->is_goto())
{
for(goto_programt::instructiont::targetst::iterator
t_it=i_it->targets.begin();
t_it!=i_it->targets.end();
t_it++)
{
new_targetst::const_iterator
result=new_targets.find(*t_it);
if(result!=new_targets.end())
*t_it=result->second;
}
}
// remove the last skip statement unless it's a target
goto_program.compute_incoming_edges();
if(!goto_program.instructions.empty() &&
is_skip(--goto_program.instructions.end()) &&
!goto_program.instructions.back().is_target())
goto_program.instructions.pop_back();
}