Bug PR26739 - Handle qualified typedef array types

CV-qualifiers of a typedef of an array type apply to the elements of
the array.  So this can be transformed into a typedef of array type
which element type is similarly CV-qualified.

That transformation helps avoiding spurious changes that might occur
when comparing the latter form against the former even though both are
equivalent.

This patch performs that transformation, just like we already do for
CV-qualified array types which are transformed into an array of
similarly CV-qualified elements.

Performing that transformation amounts to editing the type of the
array elements.  As those types might be used by other parts of the
type graph (type node sharing), the patch "clones" the type sub-tree
of interest and edits the cloned version.  That way, the shared type
nodes are not edited.  It appears that in the existing version of
maybe_strip_qualification, the transformation of CV-qualified arrays
into arrays of CV-qualified elements was unfortunately editing shared
type nodes.  The patch fixes that and re-works the logic of*
maybe_strip_qualification to make it handle this new case and the
previous one in a somewhat generic manner.

	* include/abg-fwd.h (is_typedef_of_array, clone_array)
	(clone_typedef, clone_qualified_type, clone_array_tree): Declare
	new functions.
	(peel_qualified_or_typedef_type): Declare new overload.
	(is_array_of_qualified_element): Constify the parameter.
	* include/abg-ir.h ({qualified_type,
	typedef}_def::set_underlying_type): Add new member functions.
	(array_type_def::subrange_type::subrange_type): Make constify the
	reference to the underlying type parameter.
	* src/abg-ir.cc (is_array_of_qualified_element): Constify the
	parameter.
	(peel_qualified_or_typedef_type): Define new
	overload for type_base_sptr.
	(clone_typedef_array_qualified_type): Define static function.
	(clone_array clone_typedef, clone_qualified_type)
	(clone_array_tree, is_typedef_of_array): Define new functions.
	(qualified_type_def::get_underlying_type): Rename the return type
	shared_ptr<type_base> into type_base_sptr.
	({typedef, qualified_type}_def::set_underlying_type): Define new
	member function.
	(array_type_def::subrange_type::priv::priv): Initialize the
	'infinite_' data member.
	* src/abg-dwarf-reader.cc (maybe_strip_qualification): Handle
	qualified typedef of arrays.  Merge this with the handling of
	qualified arrays.  Note that before editing the elements of the
	array to make the array (or typedef) qualifier apply to the
	element the sub-tree is cloned to make its type nodes be
	'un-shared'.  This prevents us from editing type nodes that are
	shared by other type expressions.
	* tests/data/test-diff-filter/test-PR26739-report-0.txt: New
	reference test output.
	* tests/data/test-diff-filter/test-PR26739-2-report-0.txt: Likewise.
	* tests/data/test-diff-filter/test-PR26739-v{0,1}.c: Source code
	of new binary test input.
	* tests/data/test-diff-filter/test-PR26739-2-v{0,1}.c: Likewise.
	* tests/data/test-diff-filter/test-PR26739-v{0,1}.o: New binary
	test inputs.
	* tests/data/test-diff-filter/test-PR26739-2-v{0,1}.o: Likewise.
	* tests/data/Makefile.am: Add the new test material above to
	source distribution.
	* tests/test-diff-filter.cc (in_out_specs): Add the test inputs
	above to this harness.
	* tests/data/test-annotate/test15-pr18892.so.abi: Adjust.
	* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Likewise.
	* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
	* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
	* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
	* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
	* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
	* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.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.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
27 files changed