libabigail/include
Dodji Seketeli de5de7b447 Make sure to canonicalize all types but decl-only classes
While looking at the remaining potential sources of instability in the
generation of type ids at abixml generation time, it occurred to me
that we still had several non canonicalized types in the system.

When a given type T is not canonicalized,
hash_as_canonical_type_or_constant later hashes it as an arbitrary
constant.  So in the ID hash map of the abixml writer, all the
non-canonicalized types will tend to end-up in the same hash map
bucket, so to speak.  More precisely, if T is equivalent to another
type T' which is canonicalized, then T and T' will end-up in different
buckets (in the same hash map) because they will have different hash
values as returned by hash_as_canonical_type_or_constant.  They will
thus end-up having different type-ids because they are in different
buckets.

The solution is to make sure that T is *also* canonicalized.  That
way, if T and T' are equivalent, they'll end-up in the same bucket and
they will have the same type-id.

In other words, all types should be canonicalized now.

The only exception to that rule is declaration-only classes and
unions.  The reason why a declaration-only type 'struct foo' needs to
stay non-canonicalized is that it must equal all the definitions of
'struct foo' that can be found elsewhere.

This patch thus canonicalizes all types that were not still not being
canonicalized.  It also adds an assert in
hash_as_canonical_type_or_constant to ensure that only
declaration-only class_or_union types are not canonicalized.

	* include/abg-fwd.h (is_declaration_only_class_or_union_type):
	Declare new ...
	* src/abg-ir.cc (is_declaration_only_class_or_union_type):
	... function.
	(clone_array): Add the cloned array subrange to
	its scope so that it can later be canonicalized.
	(synthesize_type_from_translation_unit)
	(synthesize_function_type_from_translation_unit): Canonicalize the
	synthesized types.
	(hash_as_canonical_type_or_constant): Ensure that all types are
	canonicalized.
	* src/abg-dwarf-reader.cc (maybe_canonicalize_type): Remove
	useless overload.
	(build_ir_node_for_variadic_parameter_type)
	(schedule_array_tree_for_late_canonicalization): Define new static
	functions.
	(maybe_strip_qualification): Schedule type canonicalization for
	types cloned prior to editing.
	(build_function_type): Use the new
	build_ir_node_for_variadic_parameter_type.  It takes care of
	canonicalizing variadic parameter types.
	(build_function_decl): Canonicalize the function type that is
	created here.
	(build_ir_node_from_die): Use the overload of
	maybe_canonicalize_type which canonicalizes class_or_union nodes
	directly, rather than the one which handles DIE offsets.  The
	latter was used as an optimization to reduce the size of the array
	of types scheduled for canonicalization, as DIE offsets take less
	space than pointers to IR types.  Now that we have DIE
	de-duplication, my bet is that we can do away with the former.
	And that also ensures that we miss no type for canonicalization
	purposes.
	* src/abg-reader.cc (build_array_type_def): Canonicalize the
	subrange types of the array.
	(build_type): Canonicalize all types.
	* tests/data/test-annotate/libtest23.so.abi: Adjust.
	* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise.
	* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-annotate/test0.abi: Likewise.
	* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
	* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* 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-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report0.txt:
	Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report1.txt:
	Likewise.
	* tests/data/test-diff-filter/test30-pr18904-rvalueref-report2.txt:
	Likewise.
	* tests/data/test-diff-filter/test35-pr18754-no-added-syms-report-0.txt:
	Likewise.
	* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi:
	Likewise.
	* tests/data/test-read-dwarf/libtest23.so.abi: Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
	* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
	* tests/data/test-read-dwarf/test0.abi: Likewise.
	* tests/data/test-read-dwarf/test0.hash.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/test13-pr18894.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.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/test20-pr19025-libvtkParallelCore-6.1.so.abi:
	Likewise.
	* tests/data/test-read-dwarf/test21-pr19092.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>
2020-11-16 09:16:09 +01:00
..
abg-comp-filter.h Support incomplete enums in core and diff code. 2020-07-08 16:59:56 +02:00
abg-comparison.h Remove unused is_reference_or_pointer_diff. 2020-07-27 15:26:04 +02:00
abg-config.h Update copyright year to 2020 2020-02-21 17:05:01 +01:00
abg-corpus.h Update copyright year to 2020 2020-02-21 17:05:01 +01:00
abg-cxx-compat.h Update copyright year to 2020 2020-02-21 17:05:01 +01:00
abg-diff-utils.h Eliminate non-ASCII characters. 2020-06-15 10:56:44 +02:00
abg-dwarf-reader.h Add --drop-undefined-syms to abidw. 2020-04-15 14:29:55 +02:00
abg-fwd.h Make sure to canonicalize all types but decl-only classes 2020-11-16 09:16:09 +01:00
abg-hash.h abg-writer: Add support for stable hash type ids. 2020-06-16 10:13:01 +02:00
abg-ini.h Update copyright year to 2020 2020-02-21 17:05:01 +01:00
abg-interned-str.h Update copyright year to 2020 2020-02-21 17:05:01 +01:00
abg-ir.h ir: Add equality op to array_type_def::subrange_type::bound_value 2020-11-13 09:19:40 +01:00
abg-libxml-utils.h Fix compilation with g++ 4.8.5 on el7 2020-05-04 13:07:24 +02:00
abg-libzip-utils.h Update copyright year to 2020 2020-02-21 17:05:01 +01:00
abg-reader.h Update copyright year to 2020 2020-02-21 17:05:01 +01:00
abg-regex.h Add POSIX regex wrapper functions. 2020-05-11 18:30:44 +02:00
abg-reporter.h Bug 26309 - Wrong leaf reporting of changes to typedef underlying type 2020-09-15 08:51:58 +02:00
abg-sptr-utils.h Move libxml bits out of abg-sptr-utils.h. 2020-05-04 11:17:30 +02:00
abg-suppression.h Make set_drops_artifact_from_ir non-const. 2020-05-11 14:36:55 +02:00
abg-tools-utils.h abg-tools-utils: Fix comment 2020-10-23 10:07:57 +02:00
abg-traverse.h Pimpl-ify traversable_base and remove its unused traverse method 2020-07-27 17:50:50 +02:00
abg-version.h.in Add (undocumented) support for version suffixes 2020-01-09 17:06:31 +00:00
abg-viz-common.h Update copyright year to 2020 2020-02-21 17:05:01 +01:00
abg-viz-dot.h Update copyright year to 2020 2020-02-21 17:05:01 +01:00
abg-viz-svg.h Update copyright year to 2020 2020-02-21 17:05:01 +01:00
abg-workers.h Update copyright year to 2020 2020-02-21 17:05:01 +01:00
abg-writer.h abg-writer: Add support for stable hash type ids. 2020-06-16 10:13:01 +02:00
Makefile.am Move regex definitions to own files. 2020-05-04 11:15:23 +02:00