libabigail/include
Dodji Seketeli 77bc4b7b15 Don't consider type name when comparing typedefs
This is from a problem report originating from Red Hat bugzilla at
https://bugzilla.redhat.com/show_bug.cgi?id=1925876

I some C programs, the same type can be defined more than once in a
binary, as there is no "One Definition Rule[1]" in C.

    [1]: https://en.wikipedia.org/wiki/One_Definition_Rule

The definition of those two types can be slightly different and yet be
equivalent.

For instance, the data member of a struct S might be defined once as
having a type which is a typedef Foo of, say, "long int" and that
struct S might be defined again elsewhere with a data member of type
typedef Bar of "long int" as well.

With the current code, because Foo and Bar have different names, they
are are going to compare different; so the two struct S are doing to
compare different even though they are equivalent.

Down the road, this is likely going to imply that the several 'struct
S' that are declaration-only will not be resolved as being
declarations of the definition of "struct S", because they is more
than one such definition, and those definitions are different.

This is going to lead to spurious (and hard to debug) type differences
that are going to be detected and reported by libabigail later down
the road.

This patch addresses the problem by not taking typedef names into
account when comparing typedefs before canonicalization.  That allows
the comparison of classes and structs that happens during the
resolution of declaration-only classes to correctly deduce their
equivalence even in cases like the one exposed above.  It thus reduces
the amount of declaration-only classes that are unnecessarily
considered to be different from the definition they ought to equal.

	* include/abg-ir.h (maybe_compare_as_member_decls): Declare new
	function.  Make it a friend of class decl_base.
	* src/abg-dwarf-reader.cc (maybe_canonicalize_type): Don't early
	canonicalize typedefs because they can be "part" of a type that is
	not yet completed, especially considering that class declaration
	resolution is part of type building, stricto sensu.
	* src/abg-ir.cc (maybe_compare_as_member_decls): Factorize this
	out of ...
	(equals): ... the overload for decl_base.  Use it in the overload
	for typedef_decl.
	* tests/data/test-diff-pkg/nmap-7.70-5.el8_testjcc.x86_64-self-check-report-0.txt:
	New test reference output.
	* tests/data/test-diff-pkg/nmap-7.70-5.el8_testjcc.x86_64.rpm: New
	binary input.
	* tests/data/test-diff-pkg/nmap-debuginfo-7.70-5.el8_testjcc.x86_64.rpm: Likewise.
	* tests/data/Makefile.am: Add these new testing material to source
	distribution.
 	* tests/test-diff-pkg.cc (in_out_specs): Add the new test input to
	the harness.
	* tests/data/test-diff-pkg/spice-server-0.12.4-19.el7.x86_64-0.12.8-1.el7.x86_64-report-0.txt:
	Adjust.
	* tests/data/test-diff-suppr/test39-opaque-type-report-0.txt:
	Adjust.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-02-11 17:23:42 +01:00
..
abg-comp-filter.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-comparison.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-config.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-corpus.h Bump ABIXML format version to 2.0 2021-02-01 14:09:29 +01:00
abg-cxx-compat.h Remove <unordered_set> usages from abg_compat 2020-12-15 09:21:38 +01:00
abg-diff-utils.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-dwarf-reader.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-fwd.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-hash.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-ini.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-interned-str.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-ir.h Don't consider type name when comparing typedefs 2021-02-11 17:23:42 +01:00
abg-libxml-utils.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-libzip-utils.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-reader.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-regex.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-reporter.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-sptr-utils.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-suppression.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-tools-utils.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-traverse.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-version.h.in Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-viz-common.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-viz-dot.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-viz-svg.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
abg-workers.h Drop unneccessary includes of abg-cxx-compat.h 2020-12-15 09:23:44 +01:00
abg-writer.h Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
Makefile.am Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00