abg-ir.cc: Add types_have_similar_structure tests.

This is a follow-up to a recent commit. This patch adds more tests, as
suggested by a reviewer.

	* src/abg-ir.cc (types_have_similar_structure): Update TODO
	regarding structure of arrays - multidimensional arrays are
	the issue.
	* tests/data/test-abidiff-exit/test-leaf-peeling-report.txt:
	Updated following changes.
	* tests/data/test-abidiff-exit/test-leaf-peeling-v0.cc: Add
	more cases (see below).
	* tests/data/test-abidiff-exit/test-leaf-peeling-v0.o:
	Updated.
	* tests/data/test-abidiff-exit/test-leaf-peeling-v1.cc: Add
	comment about a potential change to local-change semantics;
	add test cases to demonstrate that * and & and * and *** are
	structurally different; add a TODO regarding multidimensional
	arrays where changes are sometimes missed in leaf mode.
	* tests/data/test-abidiff-exit/test-leaf-peeling-v1.o

Signed-off-by: Giuliano Procida <gprocida@google.com>
This commit is contained in:
Giuliano Procida 2020-03-26 17:53:50 +00:00 committed by Dodji Seketeli
parent 9cd79d0f41
commit 95868e0c42
6 changed files with 55 additions and 19 deletions

View File

@ -22724,7 +22724,7 @@ types_have_similar_structure(const type_base* first,
if (const array_type_def* ty1 = is_array_type(first))
{
const array_type_def* ty2 = is_array_type(second);
// TODO: Handle uint32_t[10] vs uint64_t[5] better.
// TODO: Handle int[5][2] vs int[2][5] better.
if (ty1->get_size_in_bits() != ty2->get_size_in_bits()
|| ty1->get_dimension_count() != ty2->get_dimension_count()
|| !types_have_similar_structure(ty1->get_element_type(),

View File

@ -1,9 +1,9 @@
Leaf changes summary: 4 artifacts changed
Changed leaf types summary: 4 leaf types changed
Leaf changes summary: 6 artifacts changed
Changed leaf types summary: 6 leaf types changed
Removed/Changed/Added functions summary: 0 Removed, 0 Changed, 0 Added function
Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable
'struct foo at test-leaf-peeling.0.cc:1:1' changed:
'struct foo at test-leaf-peeling-v0.cc:1:1' changed:
type size changed from 32 to 64 (in bits)
there are data member changes:
type 'int' of 'foo::z' changed:
@ -12,7 +12,7 @@ Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable
and size changed from 32 to 64 (in bits) (by +32 bits)
'struct ops1 at test-leaf-peeling.0.cc:5:1' changed:
'struct ops1 at test-leaf-peeling-v0.cc:5:1' changed:
type size hasn't changed
there are data member changes:
type 'int*' of 'ops1::x' changed:
@ -20,15 +20,32 @@ Removed/Changed/Added variables summary: 0 Removed, 0 Changed, 0 Added variable
'struct ops2 at test-leaf-peeling.0.cc:9:1' changed:
'struct ops2 at test-leaf-peeling-v0.cc:9:1' changed:
type size changed from 320 to 640 (in bits)
there are data member changes:
'foo ops2::y[10]' size changed from 320 to 640 (in bits) (by +320 bits)
'struct ops3 at test-leaf-peeling.0.cc:13:1' changed:
'struct ops3 at test-leaf-peeling-v0.cc:13:1' changed:
type size hasn't changed
there are data member changes:
type 'void (int&)*' of 'ops3::spong' changed:
pointer type changed from: 'void (int&)*' to: 'void (int&&)*'
'struct ops4 at test-leaf-peeling-v0.cc:17:1' changed:
type size hasn't changed
there are data member changes:
type 'int*' of 'ops4::x' changed:
entity changed from 'int*' to 'int&'
type size hasn't changed
'struct ops5 at test-leaf-peeling-v0.cc:21:1' changed:
type size hasn't changed
there are data member changes:
type 'int*' of 'ops5::x' changed:
pointer type changed from: 'int*' to: 'int***'

View File

@ -14,11 +14,18 @@ struct ops3 {
void (*spong)(int & wibble);
};
void register_ops1(ops1*) {
}
struct ops4 {
int * x;
};
void register_ops2(ops2*) {
}
struct ops5 {
int * x;
};
void register_ops3(ops3*) {
}
int var6[2][5];
void register_ops1(ops1*) { }
void register_ops2(ops2*) { }
void register_ops3(ops3*) { }
void register_ops4(ops4*) { }
void register_ops5(ops5*) { }

View File

@ -7,6 +7,10 @@ struct ops1 {
};
struct ops2 {
// A change to foo's size is currently considered local here. Arguably this
// should be considered non-local as the change to foo is being reported
// independently. If this happens, the test case will need to be updated (to
// remove the reporting of an ops5 diff).
foo y[10];
};
@ -14,11 +18,19 @@ struct ops3 {
void (*spong)(int && wibble);
};
void register_ops1(ops1*) {
}
struct ops4 {
int & x;
};
void register_ops2(ops2*) {
}
struct ops5 {
int *** x;
};
void register_ops3(ops3*) {
}
// TODO: This *should* be considered a local change, but currently is not.
int var6[5][2];
void register_ops1(ops1*) { }
void register_ops2(ops2*) { }
void register_ops3(ops3*) { }
void register_ops4(ops4*) { }
void register_ops5(ops5*) { }