22 old_goto_functions(model_old.goto_functions),
23 ns_old(model_old.symbol_table),
24 new_goto_functions(model_new.goto_functions),
25 ns_new(model_new.symbol_table)
35 differences_mapt::const_iterator entry=
40 goto_functionst::function_mapt::const_iterator old_fit=
42 goto_functionst::function_mapt::const_iterator new_fit=
71 goto_programt::instructionst::const_iterator old_it=
73 goto_programt::instructionst::const_iterator new_it=
76 for(differencest::const_reverse_iterator rit=differences.rbegin();
77 rit!=differences.rend();
108 std::ostream &os)
const 119 for(
const auto &d : diff)
130 os <<
"/** " << identifier <<
" **/\n";
132 for(
const auto &d : diff)
170 std::size_t old_count=old_goto_program.
instructions.size();
171 std::size_t new_count=new_goto_program.
instructions.size();
173 differences.reserve(old_count+new_count);
176 goto_programt::instructionst::const_iterator old_it=
178 goto_programt::instructionst::const_iterator new_it=
196 goto_programt::instructionst::const_iterator old_rit=
198 goto_programt::instructionst::const_iterator new_rit=
201 while(old_rit!=old_it && new_rit!=new_it)
220 if(old_count==0 && new_count==0)
224 typedef std::vector<std::vector<std::size_t> > lcss_matrixt;
225 lcss_matrixt lcss_matrix(
227 std::vector<size_t>(new_count+1, 0));
230 std::size_t i=1, j=1;
231 for(goto_programt::instructionst::const_iterator old_it2=old_it;
236 for(goto_programt::instructionst::const_iterator new_it2=new_it;
241 lcss_matrix[i][j]+=lcss_matrix[i-1][j-1]+1;
244 std::max(lcss_matrix[i][j-1], lcss_matrix[i-1][j]);
252 std::cerr <<
"old_count=" << old_count <<
'\n';
253 std::cerr <<
"new_count=" << new_count <<
'\n';
254 for(i=0; i<=old_count; ++i)
256 for(j=0; j<=new_count; ++j)
259 if(lcss_matrix[i][j]<10)
261 std::cerr << lcss_matrix[i][j];
298 else if(lcss_matrix[i][j-1]<lcss_matrix[i][j])
313 for( ; old_it!=old_goto_program.
instructions.begin(); --old_it)
338 lcss(identifier, old_goto_program, new_goto_program, differences);
344 goto_functionst::function_mapt::const_iterator>
347 function_mapt old_funcs, new_funcs;
350 old_funcs.insert(std::make_pair(it->first, it));
352 new_funcs.insert(std::make_pair(it->first, it));
356 function_mapt::const_iterator ito=old_funcs.begin();
357 for(function_mapt::const_iterator itn=new_funcs.begin();
358 itn!=new_funcs.end();
362 ito!=old_funcs.end() && ito->first<itn->first;
364 unified_diff(ito->first, ito->second->second.body, empty);
366 if(ito==old_funcs.end() || itn->first<ito->first)
367 unified_diff(itn->first, empty, itn->second->second.body);
370 assert(ito->first==itn->first);
373 ito->second->second.body,
374 itn->second->second.body);
378 for( ; ito!=old_funcs.end(); ++ito)
379 unified_diff(ito->first, ito->second->second.body, empty);
390 goto_functionst::function_mapt::const_iterator f1=
392 goto_functionst::function_mapt::const_iterator f2=
instructionst instructions
The list of instructions in the goto program.
const goto_functionst & old_goto_functions
void output_diff(const irep_idt &identifier, const goto_programt &old_goto_program, const goto_programt &new_goto_program, const differencest &differences, std::ostream &os) const
unified_difft(const goto_modelt &model_old, const goto_modelt &model_new)
std::vector< differencet > differencest
differences_mapt differences_map
function_mapt function_map
Unified diff (using LCSS) of goto functions.
A specialization of goto_program_templatet over goto programs in which instructions have codet type...
void output(std::ostream &os) const
void unified_diff(const irep_idt &identifier, const goto_programt &old_goto_program, const goto_programt &new_goto_program)
bool instructions_equal(const goto_programt::instructiont &ins1, const goto_programt::instructiont &ins2, bool recurse=true) const
std::list< std::pair< goto_programt::const_targett, differencet > > goto_program_difft
void get_diff(const irep_idt &function, goto_program_difft &dest) const
#define forall_goto_functions(it, functions)
std::ostream & output_instruction(const class namespacet &ns, const irep_idt &identifier, std::ostream &out, instructionst::const_iterator it) const
See below.
const goto_functionst & new_goto_functions
void lcss(const irep_idt &identifier, const goto_programt &old_goto_program, const goto_programt &new_goto_program, differencest &differences) const