cprover
syntactic_diff.cpp
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Syntactic GOTO-DIFF
4 
5 Author: Peter Schrammel
6 
7 \*******************************************************************/
8 
11 
12 #include "syntactic_diff.h"
13 
15 {
17  {
18  if(!it->second.body_available())
19  continue;
20 
21  goto_functionst::function_mapt::const_iterator f_it=
22  goto_model2.goto_functions.function_map.find(it->first);
23  if(f_it==goto_model2.goto_functions.function_map.end() ||
24  !f_it->second.body_available())
25  {
26  deleted_functions.insert(it->first);
27  continue;
28  }
29 
30  if(it->second.body.instructions.size() !=
31  f_it->second.body.instructions.size())
32  {
33  modified_functions.insert(it->first);
34  continue;
35  }
36 
37  goto_programt::instructionst::const_iterator
38  i_it1=it->second.body.instructions.begin();
39  for(goto_programt::instructionst::const_iterator
40  i_it2=f_it->second.body.instructions.begin();
41  i_it1!=it->second.body.instructions.end() &&
42  i_it2!=f_it->second.body.instructions.end();
43  ++i_it1, ++i_it2)
44  {
45  if(i_it1->code != i_it2->code ||
46  i_it1->function != i_it2->function ||
47  i_it1->type != i_it2->type ||
48  i_it1->guard != i_it2->guard ||
49  i_it1->targets != i_it2->targets)
50  {
51  modified_functions.insert(it->first);
52  break;
53  }
54  }
55  }
57  {
58  if(!it->second.body_available())
59  continue;
60 
62 
63  goto_functionst::function_mapt::const_iterator f_it=
64  goto_model1.goto_functions.function_map.find(it->first);
65  if(f_it==goto_model1.goto_functions.function_map.end() ||
66  !f_it->second.body_available())
67  new_functions.insert(it->first);
68  }
69 
70  return !(new_functions.empty() &&
71  modified_functions.empty() &&
72  deleted_functions.empty());
73 }
const goto_modelt & goto_model1
Definition: goto_diff.h:45
virtual bool operator()()
const goto_modelt & goto_model2
Definition: goto_diff.h:46
unsigned total_functions_count
Definition: goto_diff.h:49
irep_id_sett modified_functions
Definition: goto_diff.h:51
Syntactic GOTO-DIFF.
irep_id_sett new_functions
Definition: goto_diff.h:51
irep_id_sett deleted_functions
Definition: goto_diff.h:51
#define forall_goto_functions(it, functions)
goto_functionst goto_functions
Definition: goto_model.h:26