libabigail/tests
Dodji Seketeli 59610d5572 Bug 26568 - Union should support more than one anonymous member
When building a union type we try to ensure that each member is
present only once.  This is because the code to build the union is
also used to actually update a partially constructed union.  To do so,
before adding a member to the union, the member is looked up (among
the current members) by name to see if it's already present or not.

But then for anonymous members, the name of the member is empty.
After the first anonymous member is added to the union, subsequent
look-ups with an empty name all succeed.  So no more than one
anonymous member is added to the union.  Oops.

A way to fix this is to perform the lookup by taking into account the
type of the anonymous data member, not its (empty) name.  We already
do this for anonymous data members of classes/structs.

This patch thus uses that type-based anonymous data member lookup for
unions.

But then now that unions can have several anonymous members, another
issue was uncovered.

Array types whose elements are of anonymous type can be wrongly
considered different because of canonicalization issues.

Let's suppose we have these two arrays whose internal pretty
representation are:

    "__anonymous_struct_1__ foo[5]"

and

   "__anonymous_struct_2__ foo[5]"

These are arrays of 5 elements of type anonymous struct.  Suppose the
anonymous structs "__anonymous_struct_1__" and
"__anonymous_struct_2__" are structurally equivalent.  Because the
internal names of these array element types are different, the
internal pretty representations of the arrays are different.  And thus
the canonical types of the two arrays are different.  And that's
wrong.  In this particular case, they should have the same canonical
type and thus be considered equivalent.

This patch thus teaches 'get_type_name' to make the internal type
name of anonymous types of a given kind be the same.  Thus, making all
arrays of 5 anonymous struct have the same pretty representation:

    "__anonymous_struct__ foo[5]"

This gives the type canonicalizer a chance to detect that those arrays
having the same canonical type.

These two changes while being seemingly unrelated need to be bundled
together to fix a number of issues in the existing test reference
outputs because fixing the first one is needed to uncover the later
issue.

	* src/abg-dwarf-reader.cc (add_or_update_union_type): Don't use
	the empty name of anonymous members in the lookup to ensure that
	all data members are unique.  Rather, use the whole anonymous
	member itself for the lookup, just like is done to handle
	anonymous data member in classes/structs.
	* src/abg-reader.cc (build_union_decl): Likewise.
	* src/abg-ir.cc (get_generic_anonymous_internal_type_name): Define
	new static function.
	(get_type_name): For internal purposes, make the type name of all
	anonymous types of a given kind to be the same.  This allows the
	internal representation of anonymous types which are based on type
	names to all be the same, so that they can be compared among
	themselves during type canonicalization.
	* tests/data/test-read-dwarf/test-PR26568-{1,2}.c: Source code of
	binary test input.
	* tests/data/test-read-dwarf/test-PR26568-{1,2}.o: New binary test input.
	* tests/data/test-read-dwarf/test-PR26568-{1,2}.o.abi: New
	reference test ouput.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-read-dwarf.cc (in_out_specs): Add the new binary test
	input above to this test harness.
	* tests/data/test-diff-dwarf-abixml/PR25409-librte_bus_dpaa.so.20.0.abi: Adjust.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2020-09-18 16:32:49 +02:00
..
data Bug 26568 - Union should support more than one anonymous member 2020-09-18 16:32:49 +02:00
lib Testing: add Catch Unit test framework 2020-01-28 17:16:56 +00:00
.gitignore tests/.gitignore: ignore all files starting with runtest* 2020-05-13 11:26:28 +02:00
Makefile.am tests: Add symtab test suite 2020-05-27 11:00:51 +02:00
mockfedabipkgdiff.in
print-diff-tree.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
runtestcanonicalizetypes.sh.in
runtestdefaultsupprs.py.in
runtestdefaultsupprspy3.sh.in
runtestfedabipkgdiff.py.in
runtestfedabipkgdiffpy3.sh.in
test-abicompat.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-abidiff-exit.cc Make abidiff and abidw support several --headers-dir{1,2} options 2020-09-18 10:27:18 +02:00
test-abidiff.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-alt-dwarf-file.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-annotate.cc Handle several member anonymous types of the same kind 2019-05-07 14:31:16 +02:00
test-core-diff.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-cxx-compat.cc cxx-compat: add test suite for cxx-compat 2020-05-13 11:55:12 +02:00
test-diff2.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-diff-dwarf-abixml.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-diff-dwarf.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-diff-filter.cc Bug 26309 - Wrong leaf reporting of changes to typedef underlying type 2020-09-15 08:51:58 +02:00
test-diff-pkg.cc configure: add more diagnostic options when ABIGAIL_DEVEL is set 2020-05-18 10:39:36 +02:00
test-diff-suppr.cc tests: parallelize diff-suppr test 2020-04-20 15:02:39 +02:00
test-dot.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-elf-helpers.cc abg-dwarf-reader split: create abg-elf-helpers.{h,cc} and test case 2020-04-22 11:39:45 +02:00
test-ini.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-ir-walker.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-kmi-whitelist.cc Simplify generation of symbol whitelist regex. 2020-05-04 11:17:49 +02:00
test-lookup-syms.cc dwarf-reader: Fix bloom filter access in GNU_HASH section 2020-03-20 13:35:00 +01:00
test-read-dwarf.cc Bug 26568 - Union should support more than one anonymous member 2020-09-18 16:32:49 +02:00
test-read-write.cc configure: add more diagnostic options when ABIGAIL_DEVEL is set 2020-05-18 10:39:36 +02:00
test-svg.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-symtab.cc tests: Add kernel symtab test suite 2020-05-27 11:00:51 +02:00
test-tools-utils.cc Make decl_names_equal more accurate 2020-08-04 14:51:13 +02:00
test-types-stability.cc test-types-stability: parallelize test case alternatives 2020-05-04 15:34:42 +02:00
test-utils.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-utils.h Update copyright year to 2020 2020-02-21 17:05:01 +01:00
test-valgrind-suppressions.supp
test-write-read-archive.cc Update copyright year to 2020 2020-02-21 17:05:01 +01:00
update-test-output.py