-
Notifications
You must be signed in to change notification settings - Fork 273
/
Copy pathunified_diff.h
89 lines (63 loc) · 2.07 KB
/
unified_diff.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*******************************************************************\
Module: Unified diff (using LCSS) of goto functions
Author: Michael Tautschnig
Date: April 2016
\*******************************************************************/
/// \file
/// Unified diff (using LCSS) of goto functions
#ifndef CPROVER_GOTO_DIFF_UNIFIED_DIFF_H
#define CPROVER_GOTO_DIFF_UNIFIED_DIFF_H
#include <iosfwd>
#include <list>
#include <map>
#include <vector>
#include <util/namespace.h>
#include "goto-programs/goto_program.h"
class goto_functionst;
class goto_modelt;
class unified_difft
{
public:
unified_difft(const goto_modelt &model_old, const goto_modelt &model_new);
bool operator()();
void output(std::ostream &os) const;
enum class differencet
{
SAME,
DELETED,
NEW
};
typedef std::list<std::pair<goto_programt::const_targett, differencet>>
goto_program_difft;
goto_program_difft get_diff(const irep_idt &function) const;
private:
const goto_functionst &old_goto_functions;
const namespacet ns_old;
const goto_functionst &new_goto_functions;
const namespacet ns_new;
typedef std::vector<differencet> differencest;
typedef std::map<irep_idt, differencest> differences_mapt;
void unified_diff(
const irep_idt &identifier,
const goto_programt &old_goto_program,
const goto_programt &new_goto_program);
static differencest lcss(
const goto_programt &old_goto_program,
const goto_programt &new_goto_program);
static goto_program_difft get_diff(
const goto_programt &old_goto_program,
const goto_programt &new_goto_program,
const differencest &differences);
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;
static bool instructions_equal(
const goto_programt::instructiont &ins1,
const goto_programt::instructiont &ins2);
const differences_mapt &differences_map() const;
differences_mapt differences_map_;
};
#endif // CPROVER_GOTO_DIFF_UNIFIED_DIFF_H