libabigail/tests/data/test-diff-pkg/cogl-1.22.8-2.fc33.x86_64.rpm
Dodji Seketeli 625d0903c2 Bug 26992 - Try harder to resolve declaration-only classes
When a declaration of a class, named H, matches more than one
definition (let's call them D) of H (in several other translation
units of the abi corpus) then H is left unresolved; that is, H is
considered as being a declaration-only class.  Note that down the
road, H will compare different to all those Ds.

However when those Ds are all equal, it turns out that this can lead
to issues down the road.  This is because conceptually, H equals D.
But then by not resolving H to D (and there are several Ds), we
artificially create a situation where H is different from D.  We can
even create situations where those Ds are different among themselves.
So doing comparisons inevitably leads to spurious changes.

This is the root cause of the issue described in this bug at
https://sourceware.org/bugzilla/show_bug.cgi?id=26992.

To fix the issue, this patch thus resolves H to D when the different
Ds are all equal.

Note that a similar thing should be done for the process of resolving
declaration-only enums as well.  But I don't have an issue reproducer
at hand involving enums at the moment, so I am adding a comment to
read_context::resolve_declaration_only_enums for now.

I have also filled the enhancement request
https://sourceware.org/bugzilla/show_bug.cgi?id=27189 to track a task
that would do away with read_context::resolve_declaration_only_enums
altogether by factorizing out the resolution of declaration-only
abigail::ir::decl_base.

	* src/abg-dwarf-reader.cc
	(read_context::compare_before_canonicalisation): Define new member
	function.
	(read_context::resolve_declaration_only_classes): When there are
	more than one definition that can resolve a given declaration, if
	all those definitions are equal, then resolve the declaration to
	those definitions.
	(read_context::resolve_declaration_only_enums): Add a comment to
	update similarly update this function (or do away with it
	completely) later.
	* tests/data/test-annotate/test15-pr18892.so.abi: Adjust.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-diff-pkg/cogl-1.22.8-2.fc33.x86_64.rpm: Add new
	test input.
	* tests/data/test-diff-pkg/cogl-debuginfo-1.22.8-2.fc33.x86_64.rpm:
	Likewise.
	* tests/data/test-diff-pkg/cogl-1.22.8-2.fc33.x86_64.self-check-report-0.txt:
	Likewise.
	* tests/test-diff-pkg.cc (in_out_specs): Add the new test inputs
	to the test harness.
	* tests/data/Makefile.am: Add the new test input files to source
	distribution.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-01-15 18:01:56 +01:00

497 KiB