Fix off-by one comparison bug in comparing function parameters

* src/abg-comparison.cc
	(function_decl_diff::ensure_lookup_tables_populated): Function
	parameters that are diff'ed start at the first non-implicit
	parameter, not at the first parameter.  Oops.
	* tests/data/test-diff-dwarf/test3-v0.o: New test input binary.
	* tests/data/test-diff-dwarf/test3-v0.cc: Source code for the
	binary above.
	* tests/data/test-diff-dwarf/test3-v1.o: New test input binary.
	* tests/data/test-diff-dwarf/test3-v1.cc: Source code for the
	binary above.
	* tests/data/test-diff-dwarf/test3-report.txt: Reference report
	for the diff of the new test inputs.
	* tests/test-diff-dwarf.cc: Use the test inputs above to run new
	tests.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
This commit is contained in:
Dodji Seketeli 2014-04-04 11:39:41 +02:00
parent 712320ab4c
commit 6a57f61497
7 changed files with 62 additions and 2 deletions

View File

@ -4353,7 +4353,8 @@ function_decl_diff::ensure_lookup_tables_populated()
i != priv_->parm_changes_.deletions().end();
++i)
{
parm = deleted_parameter_at(i->index());
parm = *(first_function_decl()->get_first_non_implicit_parm()
+ i->index());
parm_name = parm->get_name_id();
// If for a reason the type name is empty we want to know and
// fix that.
@ -4372,7 +4373,7 @@ function_decl_diff::ensure_lookup_tables_populated()
j != i->inserted_indexes().end();
++j)
{
parm = inserted_parameter_at(*j);
parm = *(second_function_decl()->get_first_non_implicit_parm() + *j);
parm_name = parm->get_name_id();
// If for a reason the type name is empty we want to know and
// fix that.

View File

@ -0,0 +1,13 @@
Functions changes summary: 0 Removed, 1 Changed, 0 Added function
Variables changes summary: 0 Removed, 0 Changed, 0 Added variable
1 function with some indirect sub-type change:
[C]'method void C1::foo(C0&)' has some indirect sub-type changes:
parameter 1 of type 'C0&' has sub-type changes:
in referenced type 'struct C0':
size changed from 32 to 64 bits
1 data member insertion:
'char C0::m1', at offset 32 (in bits)

View File

@ -0,0 +1,19 @@
struct C0
{
typedef int Int;
Int m0;
C0()
:m0(0)
{}
};
struct C1
{
void
foo(C0&);
};
void
C1::foo(C0&)
{}

Binary file not shown.

View File

@ -0,0 +1,21 @@
struct C0
{
typedef int Int;
Int m0;
char m1;
C0()
:m0(0),
m1(0)
{}
};
struct C1
{
void
foo(C0&);
};
void
C1::foo(C0&)
{}

Binary file not shown.

View File

@ -74,6 +74,12 @@ InOutSpec in_out_specs[] =
"data/test-diff-dwarf/test2-report.txt",
"output/test-diff-dwarf/test2-report.txt"
},
{
"data/test-diff-dwarf/test3-v0.o",
"data/test-diff-dwarf/test3-v1.o",
"data/test-diff-dwarf/test3-report.txt",
"output/test-diff-dwarf/test3-report.txt"
},
// This should be the last entry
{NULL, NULL, NULL, NULL}
};