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


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

本文整理汇总了C++中goto_programt::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ goto_programt::clear方法的具体用法?C++ goto_programt::clear怎么用?C++ goto_programt::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在goto_programt的用法示例。


在下文中一共展示了goto_programt::clear方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: goto_check

void goto_checkt::goto_check(goto_programt &goto_program)
{
  for (goto_programt::instructionst::iterator it =
      goto_program.instructions.begin(); it != goto_program.instructions.end();
      it++)
  {
    goto_programt::instructiont &i = *it;

    new_code.clear();
    assertions.clear();

    check(migrate_expr_back(i.guard));

    if (i.is_other())
    {
      if (is_code_expression2t(i.code))
      {
        check(migrate_expr_back(i.code));
      }
      else if (is_code_printf2t(i.code))
      {
        i.code->foreach_operand([this] (const expr2tc &e) {
          check(migrate_expr_back(e));
          }
        );
      }
    }
    else if (i.is_assign())
    {
      const code_assign2t &assign = to_code_assign2t(i.code);
      check(migrate_expr_back(assign.target));
      check(migrate_expr_back(assign.source));
    }
    else if (i.is_function_call())
    {
      i.code->foreach_operand([this] (const expr2tc &e) {
        check(migrate_expr_back(e));
        }
      );
    }
    else if (i.is_return())
    {
      const code_return2t &ret = to_code_return2t(i.code);
      check(migrate_expr_back(ret.operand));
    }

    for (goto_programt::instructionst::iterator i_it =
        new_code.instructions.begin(); i_it != new_code.instructions.end();
        i_it++)
    {
      i_it->local_variables = it->local_variables;
      if (i_it->location.is_nil())
      {
        if (!i_it->location.comment().as_string().empty())
          it->location.comment(i_it->location.comment());
        if (!i_it->location.property().as_string().empty())
          it->location.property(i_it->location.property());

        i_it->location = it->location;
      }
      if (i_it->function == "")
        i_it->function = it->function;
      if (i_it->function == "")
        i_it->function = it->function;
    }

    // insert new instructions -- make sure targets are not moved

    while (!new_code.instructions.empty())
    {
      goto_program.insert_swap(it, new_code.instructions.front());
      new_code.instructions.pop_front();
      it++;
    }
  }
}
开发者ID:ericksonalves,项目名称:esbmc,代码行数:76,代码来源:goto_check.cpp

示例2: goto_check

void goto_checkt::goto_check(goto_functiont &goto_function)
{
  {
    const symbolt *init_symbol;
    if(!ns.lookup(CPROVER_PREFIX "initialize", init_symbol))
      mode=init_symbol->mode;
  }

  assertions.clear();

  local_bitvector_analysist local_bitvector_analysis_obj(goto_function);
  local_bitvector_analysis=&local_bitvector_analysis_obj;

  goto_programt &goto_program=goto_function.body;

  Forall_goto_program_instructions(it, goto_program)
  {
    t=it;
    goto_programt::instructiont &i=*it;

    new_code.clear();

    // we clear all recorded assertions if
    // 1) we want to generate all assertions or
    // 2) the instruction is a branch target
    if(retain_trivial ||
       i.is_target())
      assertions.clear();

    check(i.guard);

    // magic ERROR label?
    for(optionst::value_listt::const_iterator
        l_it=error_labels.begin();
        l_it!=error_labels.end();
        l_it++)
    {
      if(std::find(i.labels.begin(), i.labels.end(), *l_it)!=i.labels.end())
      {
        goto_program_instruction_typet type=
          enable_assert_to_assume?ASSUME:ASSERT;

        goto_programt::targett t=new_code.add_instruction(type);

        t->guard=false_exprt();
        t->source_location=i.source_location;
        t->source_location.set_property_class("error label");
        t->source_location.set_comment("error label "+*l_it);
        t->source_location.set("user-provided", true);
      }
    }

    if(i.is_other())
    {
      const irep_idt &statement=i.code.get(ID_statement);

      if(statement==ID_expression)
      {
        check(i.code);
      }
      else if(statement==ID_printf)
      {
        forall_operands(it, i.code)
          check(*it);
      }
    }
    else if(i.is_assign())
    {
      const code_assignt &code_assign=to_code_assign(i.code);

      check(code_assign.lhs());
      check(code_assign.rhs());

      // the LHS might invalidate any assertion
      invalidate(code_assign.lhs());
    }
    else if(i.is_function_call())
    {
      const code_function_callt &code_function_call=
        to_code_function_call(i.code);

      // for Java, need to check whether 'this' is null
      // on non-static method invocations
      if(mode==ID_java &&
         enable_pointer_check &&
         !code_function_call.arguments().empty() &&
         code_function_call.function().type().id()==ID_code &&
         to_code_type(code_function_call.function().type()).has_this())
      {
        exprt pointer=code_function_call.arguments()[0];

        local_bitvector_analysist::flagst flags=
          local_bitvector_analysis->get(t, pointer);

        if(flags.is_unknown() || flags.is_null())
        {
          notequal_exprt not_eq_null(pointer, gen_zero(pointer.type()));

          add_guarded_claim(
            not_eq_null,
//.........这里部分代码省略.........
开发者ID:diffblue,项目名称:cbmc,代码行数:101,代码来源:goto_check.cpp

示例3: convert

void convert(const xmlt &xml, goto_programt &goto_program)
{
  goto_program.clear();
  goto_programt::instructionst &instructions = goto_program.instructions;

  xmlt::elementst::const_iterator it = xml.elements.begin();
  for(; it != xml.elements.end(); it++)
  {
    goto_programt::targett inst = goto_program.add_instruction();
    inst->targets.clear();

    if(it->name=="goto")
    {
      inst->type = GOTO;
    }
    else if(it->name=="assume")
    {
      inst->type = ASSUME;
    }
    else if(it->name=="assert")
    {
      inst->type = ASSERT;
    }
    else if(it->name=="skip")
    {
      inst->type = SKIP;
    }
    else if(it->name=="end_function")
    {
      inst->type = END_FUNCTION;
    }
    else if(it->name=="location")
    {
      inst->type = LOCATION;
    }
    else if(it->name=="dead")
    {
      inst->type = DEAD;
    }
    else if(it->name=="atomic_begin")
    {
      inst->type = ATOMIC_BEGIN;
    }
    else if(it->name=="atomic_end")
    {
      inst->type = ATOMIC_END;
    }
    else if(it->name=="return")
    {
      inst->make_return();
    }
    else if(it->name=="instruction") // OTHER
    {
      inst->make_other();
    }
    else if(it->name=="assign")
    {
      inst->make_other();
      inst->type=ASSIGN;
    }
    else if(it->name=="functioncall")
    {
      inst->make_other();
      inst->type=FUNCTION_CALL;
    }
    else if(it->name=="thread_start")
    {
      inst->type = START_THREAD;
    }
    else if(it->name=="thread_end")
    {
      inst->type = END_THREAD;
    }
    else
    {
      std::cout << "Unknown instruction type encountered (" << it->name << ")";
      std::cout << std::endl;
      return;
    }

    xmlt::elementst::const_iterator eit = it->elements.begin();
    for(; eit != it->elements.end(); eit++)
    {
      if(eit->name=="location")
      {
        convert(*eit, inst->location);
      }
      else if(eit->name=="variables")
      {
      }
      else if(eit->name=="labels")
      {
        xmlt::elementst::const_iterator lit = eit->elements.begin();
        for(; lit != eit->elements.end(); lit++)
        {
          if(lit->name=="label")
          {
            std::string ls = lit->get_attribute("name");
            inst->labels.push_back(ls);
          }
//.........这里部分代码省略.........
开发者ID:dcattaruzza,项目名称:cbmc,代码行数:101,代码来源:xml_goto_program.cpp


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