Skip to content

Commit 9ef28f4

Browse files
Compare relative goto target offsets
Goto location numbers of unmodified functions may shift when functions are added/modified/removed.
1 parent eaf3a7d commit 9ef28f4

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/goto-diff/syntactic_diff.cpp

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,22 @@ bool syntactic_difft::operator()()
4242
i_it2!=f_it->second.body.instructions.end();
4343
++i_it1, ++i_it2)
4444
{
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)
45+
long jump_difference1 = 0;
46+
if(!i_it1->targets.empty())
47+
{
48+
jump_difference1 =
49+
i_it1->get_target()->location_number - i_it1->location_number;
50+
}
51+
long jump_difference2 = 0;
52+
if(!i_it2->targets.empty())
53+
{
54+
jump_difference2 =
55+
i_it2->get_target()->location_number - i_it2->location_number;
56+
}
57+
if(
58+
i_it1->code != i_it2->code || i_it1->function != i_it2->function ||
59+
i_it1->type != i_it2->type || i_it1->guard != i_it2->guard ||
60+
jump_difference1 != jump_difference2)
5061
{
5162
modified_functions.insert(it->first);
5263
break;

0 commit comments

Comments
 (0)