Bug 27980 - Fix updating of type scope upon type canonicalization
Once a type T is canonicalized, its scope is updated so that the
vector returned by scope_decl::get_canonical_types() now contains the
new canonical type of T. This works, obviously, even when the scope
is itself a type.
This works well on binaries compiled using C only because, currently,
libabigail de-duplicates the DIEs of types. This means that if the
scope of T is a non-anonymous type, the class of equivalence of that
scope contains just one element. So updating the scope of T implies
updating just one scope.
On binaries where some files are compiled using C++ however, type DIEs
are not de-duplicated. This is just because that feature hasn't yet
been implemented in libabigail. Anyway, in that case, if the scope of
T is a non-anonymous type, the class of equivalence of that scope
contains more than one element. So updating the scope of T implies
updating the scope of all the elements of the class of equivalence T.
In practise, that means updating the canonical type (scope) of T.
Libabigail fails to update the canonical type (scope) of T. Later at
abixml emitting time, just emitting the canonical types of the scope
of T is not enough to emit the canonical type of T. And that's how
the abixml emitter forgets to emit some types as reported in the bug
https://sourceware.org/bugzilla/show_bug.cgi?id=27980.
This patch fixes that issue.
I also noticed that when emitting abixml for unions, the emitter
fails to emit the canonical member types of the union, unlike what is
done for class types. So that is fixed as well.
The binary provided in the bug report is added to the regression
testsuite.
* src/abg-ir.cc (canonicalize): Update the
scope_decl::get_canonical_types() of canonical type of the
containing type of the newly canonicalized type.
* src/abg-writer.cc (write_union_decl): Write the canonical types
contained in the current union scope, just like we do for classes.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Adjust.
* tests/data/test-types-stability/pr27980-libc.so: New binary
input file.
* tests/data/Makefile.am: Add the test input file above to source
distribution.
* tests/test-types-stability.cc (elf_paths): Add the new test
input file to this test harness.