Skip to content

Commit 3bf9987

Browse files
Compare access qualifiers in goto-diff
1 parent f71cc7f commit 3bf9987

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

src/goto-diff/syntactic_diff.cpp

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,46 @@ bool syntactic_difft::operator()()
2727
continue;
2828
}
2929

30+
// check access qualifiers
31+
const symbolt *fun1 = goto_model1.symbol_table.lookup(it->first);
32+
CHECK_RETURN(fun1 != nullptr);
33+
const symbolt *fun2 = goto_model2.symbol_table.lookup(it->first);
34+
CHECK_RETURN(fun2 != nullptr);
35+
const irep_idt &class_name = fun1->type.get(ID_C_class);
36+
bool function_access_changed =
37+
fun1->type.get(ID_access) != fun2->type.get(ID_access);
38+
bool class_access_changed = false;
39+
bool field_access_changed = false;
40+
if(!class_name.empty())
41+
{
42+
const symbolt *class1 = goto_model1.symbol_table.lookup(class_name);
43+
CHECK_RETURN(class1 != nullptr);
44+
const symbolt *class2 = goto_model2.symbol_table.lookup(class_name);
45+
CHECK_RETURN(class2 != nullptr);
46+
class_access_changed =
47+
class1->type.get(ID_access) != class2->type.get(ID_access);
48+
const class_typet &class_type1 = to_class_type(class1->type);
49+
const class_typet &class_type2 = to_class_type(class2->type);
50+
for(const auto &field1 : class_type1.components())
51+
{
52+
for(const auto &field2 : class_type2.components())
53+
{
54+
if(field1.get_name() == field2.get_name())
55+
{
56+
field_access_changed = field1.get_access() != field2.get_access();
57+
break;
58+
}
59+
}
60+
if(field_access_changed)
61+
break;
62+
}
63+
}
64+
if(function_access_changed || class_access_changed || field_access_changed)
65+
{
66+
modified_functions.insert(it->first);
67+
continue;
68+
}
69+
3070
if(it->second.body.instructions.size() !=
3171
f_it->second.body.instructions.size())
3272
{

0 commit comments

Comments
 (0)