void modelcheckert::inlinedt::build( abstract_modelt &abstract_model, const irep_idt f_id, std::set<irep_idt> &recursion_stack) { abstract_functionst::function_mapt::iterator f_it= abstract_model.goto_functions.function_map.find(f_id); if(f_it==abstract_model.goto_functions.function_map.end()) return; if(recursion_stack.find(f_id)!=recursion_stack.end()) { message.warning("Ignoring recursive call to `" + f_id.as_string() + "'."); return; } else recursion_stack.insert(f_id); abstract_programt &abstract_program=f_it->second.body; // first build target map // and do inlining typedef std::map<abstract_programt::const_targett, unsigned> target_mapt; target_mapt target_map; PC_map.reserve(PC_map.size()+abstract_program.instructions.size()); unsigned last_PC; for(abstract_programt::instructionst::iterator i_it=abstract_program.instructions.begin(); i_it!=abstract_program.instructions.end(); i_it++) { unsigned PC=PC_map.size(); PC_map.push_back(instructiont()); instructiont &instruction=PC_map.back(); instruction.original=i_it; target_map[i_it]=PC; last_PC=PC; // do function calls if(i_it->is_function_call()) { // figure out what is called const code_function_callt &call= to_code_function_call(i_it->code.concrete_pc->code); if(call.function().id()!="symbol") throw "expected symbol as function argument"; const symbol_exprt &symbol=to_symbol_expr(call.function()); build(abstract_model, symbol.get_identifier(), recursion_stack); } } // 2nd run: do targets for(abstract_programt::instructionst::iterator i_it=abstract_program.instructions.begin(); i_it!=abstract_program.instructions.end(); i_it++) { unsigned PC=target_map[i_it]; if(i_it->is_return()) // jump to end of function { PC_map[PC].targets.push_back(last_PC); } else { const abstract_programt::targetst &targets=i_it->targets; for(abstract_programt::targetst::const_iterator t_it=targets.begin(); t_it!=targets.end(); t_it++) { target_mapt::const_iterator m_it=target_map.find(*t_it); if(m_it==target_map.end()) throw "failed to find target"; PC_map[PC].targets.push_back(m_it->second); } } } recursion_stack.erase(f_id); }
// The expr2tc in position 0 is the string format const irep_idt fmt = get_string_argument(new_rhs->operands[0]); // Now we pop the format new_rhs->operands.erase(new_rhs->operands.begin()); std::list<expr2tc> args; new_rhs->foreach_operand([this, &args](const expr2tc &e) { expr2tc tmp = e; do_simplify(tmp); args.push_back(tmp); }); target->output( cur_state->guard.as_expr(), cur_state->source, fmt.as_string(), args); } void goto_symext::symex_cpp_new(const expr2tc &lhs, const sideeffect2t &code) { bool do_array; do_array = (code.kind == sideeffect2t::cpp_new_arr); unsigned int &dynamic_counter = get_dynamic_counter(); dynamic_counter++; const std::string count_string(i2string(dynamic_counter)); // value symbolt symbol;