cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
java_syntactic_diff.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Syntactic GOTO-DIFF for Java
4
5
Author: Peter Schrammel
6
7
\*******************************************************************/
8
11
12
#include "
java_syntactic_diff.h
"
13
14
#include <
goto-programs/goto_model.h
>
15
#include <
java_bytecode/java_utils.h
>
16
17
bool
java_syntactic_difft::operator()
()
18
{
19
for
(
const
auto
&gf_entry :
goto_model1
.goto_functions.function_map)
20
{
21
if
(!gf_entry.second.body_available())
22
continue
;
23
24
goto_functionst::function_mapt::const_iterator f_it =
25
goto_model2
.goto_functions.function_map.find(gf_entry.first);
26
if
(
27
f_it ==
goto_model2
.goto_functions.function_map.end() ||
28
!f_it->second.body_available())
29
{
30
deleted_functions
.insert(gf_entry.first);
31
continue
;
32
}
33
34
// check access qualifiers
35
const
symbolt
*fun1 =
goto_model1
.symbol_table.lookup(gf_entry.first);
36
CHECK_RETURN
(fun1 !=
nullptr
);
37
const
symbolt
*fun2 =
goto_model2
.symbol_table.lookup(gf_entry.first);
38
CHECK_RETURN
(fun2 !=
nullptr
);
39
const
std::optional<irep_idt> class_name =
declaring_class
(*fun1);
40
bool
function_access_changed =
41
fun1->
type
.
get
(ID_access) != fun2->
type
.
get
(ID_access);
42
bool
class_access_changed =
false
;
43
bool
field_access_changed =
false
;
44
if
(class_name)
45
{
46
const
symbolt
*class1 =
goto_model1
.symbol_table.lookup(*class_name);
47
CHECK_RETURN
(class1 !=
nullptr
);
48
const
symbolt
*class2 =
goto_model2
.symbol_table.lookup(*class_name);
49
CHECK_RETURN
(class2 !=
nullptr
);
50
class_access_changed =
51
class1->
type
.
get
(ID_access) != class2->
type
.
get
(ID_access);
52
const
class_typet
&class_type1 =
to_class_type
(class1->
type
);
53
const
class_typet
&class_type2 =
to_class_type
(class2->
type
);
54
for
(
const
auto
&field1 : class_type1.
components
())
55
{
56
for
(
const
auto
&field2 : class_type2.
components
())
57
{
58
if
(field1.get_name() == field2.get_name())
59
{
60
field_access_changed = field1.get_access() != field2.get_access();
61
break
;
62
}
63
}
64
if
(field_access_changed)
65
break
;
66
}
67
}
68
if
(function_access_changed || class_access_changed || field_access_changed)
69
{
70
modified_functions
.insert(gf_entry.first);
71
continue
;
72
}
73
74
if
(!gf_entry.second.body.equals(f_it->second.body))
75
{
76
modified_functions
.insert(gf_entry.first);
77
continue
;
78
}
79
}
80
for
(
const
auto
&gf_entry :
goto_model2
.goto_functions.function_map)
81
{
82
if
(!gf_entry.second.body_available())
83
continue
;
84
85
total_functions_count
++;
86
87
goto_functionst::function_mapt::const_iterator f_it =
88
goto_model1
.goto_functions.function_map.find(gf_entry.first);
89
if
(
90
f_it ==
goto_model1
.goto_functions.function_map.end() ||
91
!f_it->second.body_available())
92
new_functions
.insert(gf_entry.first);
93
}
94
95
return
!(
96
new_functions
.empty() &&
modified_functions
.empty() &&
97
deleted_functions
.empty());
98
}
class_typet
Class type.
Definition
std_types.h:325
goto_difft::modified_functions
std::set< irep_idt > modified_functions
Definition
goto_diff.h:54
goto_difft::goto_model1
const goto_modelt & goto_model1
Definition
goto_diff.h:49
goto_difft::new_functions
std::set< irep_idt > new_functions
Definition
goto_diff.h:54
goto_difft::total_functions_count
unsigned total_functions_count
Definition
goto_diff.h:53
goto_difft::deleted_functions
std::set< irep_idt > deleted_functions
Definition
goto_diff.h:54
goto_difft::goto_model2
const goto_modelt & goto_model2
Definition
goto_diff.h:50
irept::get
const irep_idt & get(const irep_idt &name) const
Definition
irep.cpp:44
java_syntactic_difft::operator()
virtual bool operator()()
Definition
java_syntactic_diff.cpp:17
struct_union_typet::components
const componentst & components() const
Definition
std_types.h:147
symbolt
Symbol table entry.
Definition
symbol.h:28
symbolt::type
typet type
Type of symbol.
Definition
symbol.h:31
goto_model.h
Symbol Table + CFG.
java_syntactic_diff.h
Syntactic GOTO-DIFF for Java.
declaring_class
std::optional< irep_idt > declaring_class(const symbolt &symbol)
Gets the identifier of the class which declared a given symbol.
Definition
java_utils.cpp:568
java_utils.h
CHECK_RETURN
#define CHECK_RETURN(CONDITION)
Definition
invariant.h:495
to_class_type
const class_typet & to_class_type(const typet &type)
Cast a typet to a class_typet.
Definition
std_types.h:381
jbmc
src
jdiff
java_syntactic_diff.cpp
Generated by
1.17.0