当前位置: 首页>>代码示例>>C++>>正文


C++ goto_programt::compute_incoming_edges方法代码示例

本文整理汇总了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
}
开发者ID:olivo,项目名称:BP,代码行数:48,代码来源:transform_loops.cpp

示例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();
}
开发者ID:ssvlab,项目名称:esbmc-gpu,代码行数:72,代码来源:remove_skip.cpp


注:本文中的goto_programt::compute_incoming_edges方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。