27 cfg_nodet():node_required(false)
32 #ifdef DEBUG_FULL_SLICERT
33 std::set<unsigned> required_by;
40 typedef std::vector<cfgt::entryt> dep_node_to_cfgt;
41 typedef std::stack<cfgt::entryt> queuet;
43 inline void add_to_queue(
45 const cfgt::entryt &entry,
48 #ifdef DEBUG_FULL_SLICERT
49 cfg[entry].required_by.insert(reason->location_number);
71 const auto &instruction = instruction_and_index.first;
72 const auto instruction_node_index = instruction_and_index.second;
73 if(criterion(instruction))
74 add_to_queue(queue, instruction_node_index, instruction);
76 add_to_queue(queue, instruction_node_index, instruction);
77 else if((instruction->is_goto() && instruction->guard.is_true()) ||
78 instruction->is_throw())
79 jumps.push_back(instruction_node_index);
80 else if(instruction->is_decl())
82 const auto &s=instruction->decl_symbol();
83 decl_dead[s.get_identifier()].push(instruction_node_index);
85 else if(instruction->is_dead())
87 const auto &s=instruction->dead_symbol();
88 decl_dead[s.get_identifier()].push(instruction_node_index);
94 dep_graph(goto_functions, ns);
97 fixedpoint(goto_functions, queue, jumps, decl_dead, dep_graph);
104 if(gf_entry.second.body_available())
109 if(!i_it->is_end_function() &&
112 #ifdef DEBUG_FULL_SLICERT
117 for(std::set<unsigned>::const_iterator
118 req_it=node.required_by.begin();
119 req_it!=node.required_by.end();
122 if(req_it!=node.required_by.begin())
126 i_it->source_location.set_column(c);
127 i_it->source_location.set_comment(c);
143 decl_deadt &decl_dead,
146 std::vector<cfgt::entryt> dep_node_to_cfg;
147 dep_node_to_cfg.reserve(dep_graph.
size());
149 for(
unsigned i=0; i<dep_graph.
size(); ++i)
155 while(!queue.empty())
157 while(!queue.empty())
164 if(node.node_required)
168 node.node_required=
true;
187 const cfgt::nodet &node,
190 const dep_node_to_cfgt &dep_node_to_cfg)
193 dep_graph[dep_graph[node.PC].get_node_id()];
195 for(dependence_grapht::edgest::const_iterator
196 it=d_node.
in.begin();
199 add_to_queue(queue, dep_node_to_cfg[it->first], node.PC);
239 typedef std::map<goto_programt::const_targett, unsigned>
241 typedef std::map<irep_idt, goto_program_change_impactt>
294 bool _compact_output):
295 impact_mode(_impact_mode),
296 compact_output(_compact_output),
297 old_goto_functions(model_old.goto_functions),
298 ns_old(model_old.symbol_table),
299 new_goto_functions(model_new.goto_functions),
300 ns_new(model_new.symbol_table),
301 unified_diff(model_old, model_new),
302 old_dep_graph(ns_old),
303 new_dep_graph(ns_new)
323 goto_functionst::function_mapt::const_iterator old_fit =
325 goto_functionst::function_mapt::const_iterator new_fit =
333 old_fit->second.body;
337 new_fit->second.body;
361 for(
const auto &d : diff)
368 old_impact[o_it]|=
SAME;
370 assert(n_it==d.first);
371 new_impact[n_it]|=
SAME;
376 assert(o_it==d.first);
395 assert(n_it==d.first);
413 new_impact[n_it]|=
NEW;
427 for(dependence_grapht::edgest::const_iterator it = d_node.out.begin();
428 it != d_node.out.end(); ++it)
446 dep_graph[dep_graph[src].get_node_id()],
460 for(dependence_grapht::edgest::const_iterator it = d_node.in.begin();
461 it != d_node.in.end(); ++it)
482 dep_graph[dep_graph[src].get_node_id()],
493 goto_functionst::function_mapt::const_iterator>
496 function_mapt old_funcs, new_funcs;
502 old_funcs.insert(std::make_pair(it->first, it));
508 new_funcs.insert(std::make_pair(it->first, it));
511 function_mapt::const_iterator ito=old_funcs.
begin();
512 for(function_mapt::const_iterator itn=new_funcs.begin();
513 itn!=new_funcs.end();
516 while(ito!=old_funcs.end() && ito->first<itn->first)
519 if(ito!=old_funcs.end() && itn->first==ito->first)
527 goto_functions_change_impactt::const_iterator oc_it=
529 for(goto_functions_change_impactt::const_iterator
551 assert(oc_it->first==nc_it->first);
573 goto_functionst::function_mapt::const_iterator f_it =
579 std::cout <<
"/** " << function_id <<
" **/\n";
583 goto_program_change_impactt::const_iterator c_entry=
585 const unsigned mod_flags =
586 c_entry == c_i.end() ?
static_cast<unsigned>(
SAME) : c_entry->second;
595 else if(mod_flags&
NEW)
621 goto_functionst::function_mapt::const_iterator o_f_it =
626 goto_functionst::function_mapt::const_iterator f_it =
632 std::cout <<
"/** " << function_id <<
" **/\n";
638 goto_program_change_impactt::const_iterator o_c_entry=
639 o_c_i.find(o_target);
640 const unsigned old_mod_flags = o_c_entry == o_c_i.end()
641 ?
static_cast<unsigned>(
SAME)
652 goto_program_change_impactt::const_iterator c_entry=
654 const unsigned mod_flags =
655 c_entry == n_c_i.end() ?
static_cast<unsigned>(
SAME) : c_entry->second;
662 if(old_mod_flags==
SAME)
675 else if(mod_flags&
NEW)
681 assert(old_mod_flags==
SAME ||
690 assert(old_mod_flags==
SAME ||
704 goto_program_change_impactt::const_iterator o_c_entry=
705 o_c_i.find(o_target);
706 const unsigned old_mod_flags = o_c_entry == o_c_i.end()
707 ?
static_cast<unsigned>(
SAME)
713 if(old_mod_flags==
SAME)
717 else if(old_mod_flags&
NEW)
740 const irep_idt &file = target->source_location().get_file();
741 const irep_idt &line = target->source_location().get_line();
743 std::cout << prefix <<
" " <<
id2string(file)
749 target->output(std::cout);
759 change_impactt c(model_old, model_new, impact_mode, compact_output);