Prevent build_function_type from not canonicalizing certain types
authorDodji Seketeli <dodji@redhat.com>
Fri, 2 Oct 2015 16:27:34 +0000 (18:27 +0200)
committerDodji Seketeli <dodji@redhat.com>
Sun, 4 Oct 2015 11:51:25 +0000 (13:51 +0200)
commit501c514245526cb6a309f5e4eae82f0a6c8b4250
treee5aef8ba10baf93ef90ed76f1f8189a4428ac944
parent21e159a66e30b9efd3e7053a3ec0bcf3bc8120cc
Prevent build_function_type from not canonicalizing certain types

I noticed that in some cases in build_function_type, when building the
sub-types of the function type, the construction of a function type
for the same DIE could be triggered.  This happens frequently for
aggregate types that happen to be recursive.  In those cases, we must
arrange for the construction of the function type for the same DIE to
return the same type that is being currently built by
build_function_type; otherwise, several types are going to be built
for the same DIE, and only one of them is going to be canonicalized.
build_function_type was just not prepared for this.

This patch fixes that.

Please note that the patch changes the test output
/home/dodji/git/libabigail.git/merge/build/tests/output/test-read-dwarf/test12-pr18844.so.abi
but it's a later patch that adjust that file because several patches
are going to require an update to that file.  We are going to update
that patch in one go at the end of the patch series.

* src/abg-dwarf-reader.cc (build_function_type): Associate the
type being built with its DIE, before starting to build the
sub-types.  The current type is then amended with the sub-types
that are built later.
(build_ir_node_from_die): In the case for DW_TAG_subroutine_type,
do not associate the type to the DIE here, as it's been done in
build_function_type.
* src/abg-ir.cc (function_type::set_parameters): Adjust the index
of the parameters being set to the function: they start at 1,
unless the first parameter is artificial, in which case its index
starts at zero.  This is just like what is done when the function
type is constructed directly with the parameters passed as an
argument to the constructor.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-dwarf-reader.cc
src/abg-ir.cc