Skip to content

Commit

Permalink
Compare access qualifiers in goto-diff
Browse files Browse the repository at this point in the history
  • Loading branch information
peterschrammel committed Jan 17, 2018
1 parent f71cc7f commit 3bf9987
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/goto-diff/syntactic_diff.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,46 @@ bool syntactic_difft::operator()()
continue;
}

// check access qualifiers
const symbolt *fun1 = goto_model1.symbol_table.lookup(it->first);
CHECK_RETURN(fun1 != nullptr);
const symbolt *fun2 = goto_model2.symbol_table.lookup(it->first);
CHECK_RETURN(fun2 != nullptr);
const irep_idt &class_name = fun1->type.get(ID_C_class);
bool function_access_changed =
fun1->type.get(ID_access) != fun2->type.get(ID_access);
bool class_access_changed = false;
bool field_access_changed = false;
if(!class_name.empty())
{
const symbolt *class1 = goto_model1.symbol_table.lookup(class_name);
CHECK_RETURN(class1 != nullptr);
const symbolt *class2 = goto_model2.symbol_table.lookup(class_name);
CHECK_RETURN(class2 != nullptr);
class_access_changed =
class1->type.get(ID_access) != class2->type.get(ID_access);
const class_typet &class_type1 = to_class_type(class1->type);
const class_typet &class_type2 = to_class_type(class2->type);
for(const auto &field1 : class_type1.components())
{
for(const auto &field2 : class_type2.components())
{
if(field1.get_name() == field2.get_name())
{
field_access_changed = field1.get_access() != field2.get_access();
break;
}
}
if(field_access_changed)
break;
}
}
if(function_access_changed || class_access_changed || field_access_changed)
{
modified_functions.insert(it->first);
continue;
}

if(it->second.body.instructions.size() !=
f_it->second.body.instructions.size())
{
Expand Down

0 comments on commit 3bf9987

Please sign in to comment.