Fix size calculations for multidimensional arrays.

The code in abg-ir.cc that calculated the memory size of an array
summed, rather than multiplied, the dimensions. It also did duplicate
work for each dimension after the first.

Existing code in abg-reader.cc asserted that array size information
read from XML match freshly calculated values.

This patch corrects the calculation, eliminates the duplicate work and
updates the XML reader validation to just emit a warning if old bad
array size information is found.

	* include/abg-ir.h (array_type_def::append_subrange): Remove
	this function.
	* src/abg-ir.cc (array_type_def::set_element_type): Add a note
	about safe usage.
	(array_type_def::append_subrange): Inline this function into
	its only caller append_subranges and remove it.
	(array_type_def::append_subranges): Do correct multiplicative
	calculation of multidimensional array sizes.
	* src/abg-reader.cc (build_array_type_def): When checking
	calculated against read array sizes, warn once if value
	matches old behaviour rather than raising an assertion.
	Otherwise, before raising an assertion, emit an informative
	error message.
	* tests/data/test-annotate/test14-pr18893.so.abi: Correct
	array sizes.
	* tests/data/test-annotate/test17-pr19027.so.abi: Ditto.
	* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
	Ditto.
	* tests/data/test-annotate/test7.so.abi: Ditto.
	* tests/data/test-diff-dwarf/test10-report.txt: Ditto.
	* tests/data/test-diff-dwarf/test11-report.txt: Ditto.
	* tests/data/test-read-write/test25.xml: Ditto.

Reviewed-by: Matthias Maennich <maennich@google.com>
Signed-off-by: Giuliano Procida <gprocida@google.com>
10 files changed