Exemplo n.º 1
0
void all_paths_enumeratort::complete_path(patht &path, int succ)
{
  if(path.empty())
    return;

  path_nodet &node=path.back();
  extend_path(path, node.loc, succ);

  goto_programt::targett end=path.back().loc;

  if(end==loop_header || loop.find(end)==loop.end())
    return;

  complete_path(path, 0);
}
Exemplo n.º 2
0
int all_paths_enumeratort::backtrack(patht &path) {
  // If we have a path of length 1 or 0, we can't backtrack any further.
  // That means we're done enumerating paths!
  if (path.size() < 2) {
    path.clear();
    return 0;
  }

  path_nodet &node = path.back();
  path.pop_back();

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

  int ret = 0;

  for (goto_programt::targetst::iterator it = succs.begin();
       it != succs.end();
       ++it) {
    if (*it == node.loc) {
      break;
    }

    ret++;
  }

  if ((ret + 1) < succs.size()) {
    // We can take the next branch here...

#ifdef DEBUG
    std::cout << "Backtracked to a path of size " << path.size() << std::endl;
#endif

    return ret + 1;
  }

  // Recurse.
  return backtrack(path);
}
Exemplo n.º 3
0
int all_paths_enumeratort::backtrack(patht &path)
{
  // If we have a path of length 1 or 0, we can't backtrack any further.
  // That means we're done enumerating paths!
  if(path.size()<2)
  {
    path.clear();
    return 0;
  }

  path_nodet &node=path.back();
  path.pop_back();

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

  unsigned int ret=0;

  for(const auto &succ : succs)
  {
    if(succ==node.loc)
      break;

    ret++;
  }

  if((ret+1)<succs.size())
  {
    // We can take the next branch here...

#ifdef DEBUG
    std::cout << "Backtracked to a path of size " << path.size() << '\n';
#endif

    return ret+1;
  }

  // Recurse.
  return backtrack(path);
}
Exemplo n.º 4
0
bool all_paths_enumeratort::is_looping(patht &path) {
  return path.size() > 1 && path.back().loc == loop_header;
}