XML writer: use consistent type pointers for type ids and emission tracking
Insertion uses the canonical type, if available, but look-up did
not. Given that type id insertion and look-up also use canonical
types, it makes sense to adjust the remaining code accordingly.
Neither decl_only_type_is_emitted nor record_decl_only_type_as_emitted
do the check, but very few types end up being recorded this way.
The functions write_class_decl and write_union_decl (but not
write_class_decl_opening_tag and write_union_decl_opening_tag which
can be called in other contexts) resolve declaration-only types to a
definition where possible.
To ensure type ids consistently refer to the same canonical type we
should use canonical types and definitions-of-declarations more
consistently.
This change introduces get_exemplar_type to return the exemplar type
that should be used for type id and emitted checks. That exemplar
type is the canonical type of a given type, or the canonical type of
the definition-of-declaration-only-type when applicable.
However, it does not also change all the write functions to write out
the exemplar types.
* include/abg-fwd.h (get_exemplar_type): Declare new function.
* src/abg-ir.cc (get_exemplar_type): Define new function.
* src/abg-writer.cc (type_has_existing_id): use get_exemplar_type
for resolution.
(get_id_for_type): Likewise.
(record_type_as_emitted): Likewise.
(type_is_emitted): Likewise.