libabigail/include
Dodji Seketeli ca08bae742 RHBZ 1925886 - Compare anonymous types without qualified names
An anonymous struct/union is, by definition an entity that is not
named (unless a naming typedef is provided for it).

It turns out that in C++ binaries, there are anonymous types that are
logically equivalent (as far as ABI is concerned) because they have
the same members and layout, but turn out to be evaluated as being
different because they are defined in different name spaces.  And
because they are not named, showing them as being different just
because of their name space doesn't bring anything but spurious error
reporting.

Consider the DWARF representing this:

struct S
{
  union
  {
   int a;
   int b;
  } member;
};

where the 'member' is of type S::<anonymous-union>.

Probably due to LTO, we see some DWARF that represents the type of
'member' as just <anonymous-union>, in some translation units.

I could not generate that DWARF from a small test case, myself.  But
it comes from the binary 'usr/bin/lto-dump', from the
https://bugzilla.redhat.com/show_bug.cgi?id=1925886 problem report.

So in that case, we want the S::<anonymous-union> to compare equal to
the <anonymous-union>, otherwise, this produces spurious type changes,
especially when doing self comparison.

This is what this patch does.

	* include/abg-fwd.h (is_anonymous_type): Constify this function.
	* src/abg-ir.cc (equals): In the overload for decl_base, do not
	take scope of anonymous types into account.  In the overload for
	array_type_def do not peel of typedefs.  This is not directly
	related to anonymous types, but it make comparison more robust
	against naming typedefs used for anonymous types in array
	elements.
	(get_type_name): Do not take into account the scope of anonymous
	types when building internal representation of types.  Note that
	the internal representation is what is used for canonicalization.
	This means that all anonymous types are compared against each
	others during type canonicalization.
	* src/abg-reader.cc (build_class_decl): Do not try to re-use
	anonymous types, just like we already do for DWARF.
	* tests/data/test-annotate/test17-pr19027.so.abi: Adjust.
	* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-0.txt:
	Likewise.
	* tests/data/test-diff-filter/test31-pr18535-libstdc++-report-1.txt:
	Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libaaudio.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
	* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test22-pr19097-libstdc++.so.6.0.17.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
2021-08-11 17:39:54 +02: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 Consistently use std::unique_ptr for private implementations (pimpl) 2021-07-16 11:16:47 +02: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 Consistently use std::unique_ptr for private implementations (pimpl) 2021-07-16 11:16:47 +02:00
abg-cxx-compat.h abg-cxx-compat: add simplified version of std::optional 2021-03-09 10:41:10 +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 dwarf reader: drop (now) unused code related to symbol table reading 2021-04-02 15:48:23 +02:00
abg-fwd.h RHBZ 1925886 - Compare anonymous types without qualified names 2021-08-11 17:39:54 +02: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 Consistently use std::unique_ptr for private implementations (pimpl) 2021-07-16 11:16:47 +02:00
abg-interned-str.h Consistently use std::unique_ptr for private implementations (pimpl) 2021-07-16 11:16:47 +02:00
abg-ir.h Bug 27236 - Fix the canonical type propagation optimization 2021-08-11 17:39:11 +02:00
abg-libxml-utils.h reader: Use xmlFirstElementChild and xmlNextElementSibling rather than xml::advance_to_next_sibling_element 2021-05-03 17:15:22 +02:00
abg-reader.h Detect abixml canonical type instability during abidw --debug-abidiff 2021-05-25 12:24:26 +02: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 Consistently use std::unique_ptr for private implementations (pimpl) 2021-07-16 11:16:47 +02:00
abg-tools-utils.h Consistently use std::unique_ptr for private implementations (pimpl) 2021-07-16 11:16:47 +02:00
abg-traverse.h Consistently use std::unique_ptr for private implementations (pimpl) 2021-07-16 11:16:47 +02: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 Consistently use std::unique_ptr for private implementations (pimpl) 2021-07-16 11:16:47 +02:00
abg-writer.h Bug 27236 - Don't forget to emit some referenced types 2021-08-11 17:39:49 +02:00
Makefile.am Bug 27512 - Remove broken zip-archive support 2021-03-19 10:52:57 +01:00