xml reader: Fix recursive qualified & reference type definition
This is a followup patch for the fix for
https://bugzilla.redhat.com/show_bug.cgi?id=
1944088, which was in the
patch:
commit
51ae965305f9eaa554d5d2111fa24eeb07d35244
Author: Dodji Seketeli <dodji@redhat.com>
Date: Fri May 21 23:55:44 2021 +0200
abixml reader: Fix recursive type definition handling
After that patch, I noticed that qualified and reference types also
need to be able to handle the case where their underlying/pointed-to
type recursively refers to the type being created. Just like typedef
and pointer types in that patch.
This patch thus adjusts build_qualified_type_decl and
build_reference_type_def to support that. It also adjusts the
qualified_type_def and reference_type_def classes to support being
created without underlying/pointed-to type initially.
* include/abg-ir.h (qualified_type_def::qualified_type_def):
Declare a constructor with no underlying type.
(reference_type_def::reference_type_def): Declare a constructor
with no pointed-to type.
(reference_type_def::set_pointed_to_type): Declare new method.
* src/abg-ir.cc (qualified_type_def::priv::priv): Define a
constructor that takes no underlying type.
(qualified_type_def::build_name): Make this work even on
incomplete types with no underlying type. In that case, this
behaves like if the underlying type is "void".
(qualified_type_def::qualified_type_def): Define a constructor
that takes no underlying type.
(qualified_type_def::get_size_in_bits): Make this work on
incomplete types with no underlying type.
(qualified_type_def::set_underlying_type): Adjust to properly
update this type when a new underlying type is set. Particularly,
its name and the lookup maps from the type scope.
(reference_type_def::reference_type_def): Define a constructor
that takes no pointed-to type.
(reference_type_def::set_pointed_to_type): Define new function.
* src/abg-reader.cc (build_qualified_type_decl): Construct the
qualified type early before we try to construct its underlying
type. Associate this incomplete type with the type-id. Then try
to construct the underlying type. During its construction, if
this incomplete qualified type is needed due to recursion then it
can be used, leading to just one qualified type being used as it
should be.
(build_reference_type_def): Likewise for building incomplete
reference type first before its pointed-to type.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>