mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-14 14:04:45 +00:00
d00a2cc2da
Since this commit:
commit 43cbdd1501
Author: Dodji Seketeli <dodji@redhat.com>
Date: Thu Apr 13 16:48:52 2023 +0200
ir: Recognize "void* as being equal to all other pointers in C
a pointer to void is considered equal to all other pointers to avoid
emitting some spurious changes while self-comparing glibc from fc37.
As a void pointer can now equal several kinds of types, it could no
longer be canonicalized. But then, the 'exemplar pointer' based
optimization in the ABIXML writer (cf get_exemplar_type) makes it so
that two different void pointer IR nodes (that are structurally
equivalent) would result in two different nodes (with different
type-ids) being serialized out in ABIXML. Later at ABIXML reading
time, aggregates types using these two different void pointer nodes
might yield canonical types that are different from the original ones,
depending on the order in which ABIXML types are canonicalized as that
order might differ from the order in which they were initially
canonicalized. This difference leads to spurious self-comparison
errors.
To handle this, I am proposing that the void pointer type be a unique
IR type node in the system. That way, the exemplar type optimization
would still work and we get rid of the spurious self-comparison error
change. While doing this, I realized that the void type and the
variadic parameter type that are also unique types were not properly
enforced in all the front-ends as such. So this patch fixes that.
The patch also make typedefs and pointer to decl-only classes be
non-canonicalized types because decl-only classes are non-canonicalized
already. Pointers and typedefs to those types being canonicalized can
lead to different canonicalized type depending on the order of
canonicalization.
The rest of the patch is basically adjusting the other moving parts to
these core changes.
* include/abg-fwd.h (is_pointer_to_decl_only_class_or_union_type)
(is_reference_to_decl_only_class_or_union_type)
(is_typedef_to_decl_only_class_or_union_type)
(is_void_pointer_type_equivalent, is_unique_type): Declare new
functions.
(is_typedef, is_void_pointer_type): Declare new overloads.
(is_declaration_only_class_or_union_type): Add a new
look_through_decl_only flag as parameter.
* include/abg-ir.h (environment::{get_void_pointer_type,
is_void_pointer_type}): Define new member functions.
* src/abg-ir-priv.h (environment::priv::{void_pointer_type}): Add
new data member.
* src/abg-ir.cc (decl_topo_comp::operator()): For unique types,
use lexicographic sorting.
(environment::{get_void_pointer_type, is_void_pointer_type}):
Define new member function.
(is_typedef, is_pointer_to_decl_only_class_or_union_type)
(is_reference_to_decl_only_class_or_union_type)
(is_typedef_to_decl_only_class_or_union_type, is_unique_type):
Define new functions.
(is_declaration_only_class_or_union_type): Add a new
look_through_decl_only parameter. Some decl-only class or union
do have an associated definition; this function return false for
these types if look_through_decl_only is set to true.
(is_void_pointer_type_equivalent): Rename is_void_pointer_type
into this.
(is_void_pointer_type): Now that is_void_pointer_type equals is
old version of this is_void_poitner, make the new version test if
the type equals the unique void pointer type, or if it a pointer
to void type. It doesn't take typedefs into account, like what
is_void_pointer_type_equivalent does.
(equals): In the overload for pointer_type_def, use the new
is_void_pointer_type_equivalent instead of
is_void_pointer_type_equivalent.
(is_non_canonicalized_type): Re-organize this. Now, all unique
types are non-canonicalized. This was sort-of the case already
but was not clearly stated as such. The decl-only class-or-union
types were already non-canonicalized, but pointers and typedefs to
class-or-unions should also be non-canonicalized for the system to
work because a decl-only class-or-unions equals all defined types
in C++.
* src/abg-btf-reader.cc
(reader::build_ir_node_for_void_pointer_type): Define new member
function that return a unique type for void pointer types.
(reader::build_pointer_type): Use
build_ir_node_for_void_pointer_type to build void pointer types.
(reader::{build_ir_node_for_void_type,
build_ir_node_for_variadic_parameter_type}): Simplify.
* src/abg-ctf-reader.cc (build_ir_node_for_void_type)
(build_ir_node_for_void_pointer_type): Define new functions.
(process_ctf_function_type): Use build_ir_node_for_void_type for
void types.
(process_ctf_pointer_type): Use
build_ir_node_for_void_pointer_type for void pointer types.
* src/abg-dwarf-reader.cc (build_ir_node_for_void_pointer_type):
Define a new function that returns a unique type for void pointer
types.
(build_pointer_type_def): Use the new
build_ir_node_for_void_pointer_type to build void pointers.
(build_ir_node_for_variadic_parameter_type): Simplify.
* src/abg-reader.cc (read_type_id_string): Define this even
not debugging self-comparison.
(build_ir_node_for_void_type)
(build_ir_node_for_void_pointer_type): Define new functions.
(reader::{get_scope_for_node, get_scope_ptr_for_node}): New member
functions.
(reader::push_decl_to_current_scope): Remove this member function.
This was using the scope of the last IR node built as the current
scope. The problem is that the scope of a unique IR node is the
scope where it was used the first time; that has nothing to do
with the current scope. So this function is obsolete now that we
are using unique IR nodes for real.
(reader::push_decl_to_scope): New member function. This is the
one to use, now that push_decl_to_current_scope is no more.
(reader::push_and_key_type_decl): Pass the scope_decl to use.
Make this push the decl to the scope passed in parameter. Add an
overload that has the XML node to use to determine the scope to
push the decl to.
(reader::get_scope_for_node): Support template parameter type
composition nodes. Also, add an overload that takes just an XML
node.
(reader::get_scope_ptr_for_node): Define new member function.
(build_namespace_decl, build_function_decl, build_var_decl): Use
to reader::push_decl_to_scope, now that
reader::push_decl_to_current_scope is gone.
(build_type_decl): Use build_ir_node_for_void_type to build a void
type. Adjust the call to reader::push_and_key_type_decl.
(build_qualified_type_decl, build_reference_type_def)
(build_subrange_type, build_array_type_def, build_enum_type_decl)
(build_typedef_decl, build_class_decl, build_union_decl)
(build_function_tdecl, build_function_tdecl, build_class_tdecl)
(build_type_tparameter, build_type_composition)
(build_non_type_tparameter, build_template_tparameter): Adjust the
call to reader::push_and_key_type_decl.
(build_pointer_type_def): Likewise. Use
build_ir_node_for_void_pointer_type to build a void pointer IR
node. Also, build the pointed-to-type before the pointer type
itself; this is required to catch a void pointer type early and
use build_ir_node_for_void_pointer_type to build it.
* src/abg-comp-filter.cc (has_void_ptr_to_ptr_change): Use the new
is_void_pointer_type_equivalent in lieu of is_void_pointer_type.
This is because the former takes typedefs into account and so is
more accurate.
* src/abg-comparison.cc
(scope_diff::ensure_lookup_tables_populated): Do not consider
unique types when accounting for added/removed types.
* tests/data/test-annotate/libtest23.so.abi: Adjust.
* tests/data/test-annotate/libtest24-drop-fns-2.so.abi: Likewise.
* tests/data/test-annotate/libtest24-drop-fns.so.abi: Likewise.
* tests/data/test-annotate/test-anonymous-members-0.o.abi: Likewise.
* tests/data/test-annotate/test0.abi: Likewise.
* tests/data/test-annotate/test1.abi: Likewise.
* tests/data/test-annotate/test13-pr18894.so.abi: Likewise.
* tests/data/test-annotate/test14-pr18893.so.abi: Likewise.
* tests/data/test-annotate/test15-pr18892.so.abi: Likewise.
* tests/data/test-annotate/test17-pr19027.so.abi: Likewise.
* tests/data/test-annotate/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
Likewise.
* tests/data/test-annotate/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Likewise.
* tests/data/test-annotate/test2.so.abi: Likewise.
* tests/data/test-annotate/test20-pr19025-libvtkParallelCore-6.1.so.abi:
Likewise.
* tests/data/test-annotate/test21-pr19092.so.abi: Likewise.
* tests/data/test-annotate/test3.so.abi: Likewise.
* tests/data/test-annotate/test5.o.abi: Likewise.
* tests/data/test-read-btf/test1.o.abi: Likewise.
* tests/data/test-read-ctf/test2.so.abi: Likewise.
* tests/data/test-read-ctf/test2.so.hash.abi: Likewise.
* tests/data/test-read-ctf/test8.o.abi: Likewise.
* tests/data/test-read-dwarf/PR22015-libboost_iostreams.so.abi:
Likewise.
* tests/data/test-read-dwarf/PR22122-libftdc.so.abi: Likewise.
* tests/data/test-read-dwarf/PR24378-fn-is-not-scope.abi:
Likewise.
* tests/data/test-read-dwarf/PR25007-sdhci.ko.abi: Likewise.
* tests/data/test-read-dwarf/PR25042-libgdbm-clang-dwarf5.so.6.0.0.abi:
Likewise.
* tests/data/test-read-dwarf/PR27700/test-PR27700.abi: Likewise.
* tests/data/test-read-dwarf/libtest23.so.abi: Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns-2.so.abi:
Likewise.
* tests/data/test-read-dwarf/libtest24-drop-fns.so.abi: Likewise.
* tests/data/test-read-dwarf/test-PR26568-1.o.abi: Likewise.
* tests/data/test-read-dwarf/test-PR26568-2.o.abi: Likewise.
* tests/data/test-read-dwarf/test-libaaudio.so.abi: Likewise.
* tests/data/test-read-dwarf/test-libandroid.so.abi: Likewise.
* tests/data/test-read-dwarf/test-suppressed-alias.o.abi:
Likewise.
* tests/data/test-read-dwarf/test0.abi: Likewise.
* tests/data/test-read-dwarf/test0.hash.abi: Likewise.
* tests/data/test-read-dwarf/test1.abi: Likewise.
* tests/data/test-read-dwarf/test1.hash.abi: Likewise.
* tests/data/test-read-dwarf/test10-pr18818-gcc.so.abi: Likewise.
* tests/data/test-read-dwarf/test11-pr18828.so.abi: Likewise.
* tests/data/test-read-dwarf/test12-pr18844.so.abi: Likewise.
* tests/data/test-read-dwarf/test13-pr18894.so.abi: Likewise.
* tests/data/test-read-dwarf/test14-pr18893.so.abi: Likewise.
* tests/data/test-read-dwarf/test15-pr18892.so.abi: Likewise.
* tests/data/test-read-dwarf/test16-pr18904.so.abi: Likewise.
* tests/data/test-read-dwarf/test17-pr19027.so.abi: Likewise.
* tests/data/test-read-dwarf/test18-pr19037-libvtkRenderingLIC-6.1.so.abi:
Likewise.
* tests/data/test-read-dwarf/test19-pr19023-libtcmalloc_and_profiler.so.abi:
Likewise.
* tests/data/test-read-dwarf/test2.so.abi: Likewise.
* tests/data/test-read-dwarf/test2.so.hash.abi: Likewise.
* tests/data/test-read-dwarf/test20-pr19025-libvtkParallelCore-6.1.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.
* tests/data/test-read-dwarf/test3-alias-1.so.hash.abi: Likewise.
* tests/data/test-read-dwarf/test3-alias-2.so.hash.abi: Likewise.
* tests/data/test-read-dwarf/test3-alias-3.so.hash.abi: Likewise.
* tests/data/test-read-dwarf/test3-alias-4.so.hash.abi: Likewise.
* tests/data/test-read-dwarf/test3.so.abi: Likewise.
* tests/data/test-read-dwarf/test3.so.hash.abi: Likewise.
* tests/data/test-read-dwarf/test5.o.abi: Likewise.
* tests/data/test-read-dwarf/test5.o.hash.abi: Likewise.
* tests/data/test-read-dwarf/test9-pr18818-clang.so.abi: Likewise.
* tests/data/test-read-write/test17.xml: Likewise.
* tests/data/test-read-write/test18.xml: Likewise.
* tests/data/test-read-write/test19.xml: Likewise.
* tests/data/test-read-write/test20.xml: Likewise.
* tests/data/test-read-write/test21.xml: Likewise.
* tests/data/test-read-write/test22.xml: Likewise.
* tests/data/test-read-write/test23.xml: Likewise.
* tests/data/test-read-write/test26.xml: Likewise.
* tests/data/test-read-write/test27.xml: Likewise.
* tests/data/test-read-write/test28-without-std-fns-ref.xml:
Likewise.
* tests/data/test-read-write/test28-without-std-vars-ref.xml:
Likewise.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
47 lines
2.9 KiB
XML
47 lines
2.9 KiB
XML
<abi-instr path='data/test-read-write/test21.xml'>
|
|
<type-decl name='int' size-in-bits='32' alignment-in-bits='32' id='type-id-1'/>
|
|
<class-decl name='S' size-in-bits='32' alignment-in-bits='32' visibility='default' filepath='simple-class-0.C' line='5' column='8' id='type-id-2'>
|
|
<member-type access='public'>
|
|
<typedef-decl name='S' type-id='type-id-2' filepath='simple-class-0.C' line='6' column='1' id='type-id-3'/>
|
|
</member-type>
|
|
<data-member access='public' layout-offset-in-bits='0'>
|
|
<var-decl name='m' type-id='type-id-1' visibility='default' filepath='simple-class-0.C' line='7' column='7'/>
|
|
</data-member>
|
|
<member-function access='public' constructor='yes'>
|
|
<function-decl name='__base_ctor ' mangled-name='_ZN1SC2Ev' filepath='simple-class-0.C' line='13' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'>
|
|
<parameter type-id='type-id-4'/>
|
|
<return type-id='type-id-5'/>
|
|
</function-decl>
|
|
</member-function>
|
|
<member-function access='public' constructor='yes'>
|
|
<function-decl name='__comp_ctor ' mangled-name='_ZN1SC1Ev' filepath='simple-class-0.C' line='13' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'>
|
|
<parameter type-id='type-id-4'/>
|
|
<return type-id='type-id-5'/>
|
|
</function-decl>
|
|
</member-function>
|
|
<member-function access='public' constructor='yes'>
|
|
<function-decl name='__base_ctor ' mangled-name='_ZN1SC2ERKS_' filepath='simple-class-0.C' line='18' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'>
|
|
<parameter type-id='type-id-4'/>
|
|
<parameter type-id='type-id-6'/>
|
|
<return type-id='type-id-5'/>
|
|
</function-decl>
|
|
</member-function>
|
|
<member-function access='public' constructor='yes'>
|
|
<function-decl name='__comp_ctor ' mangled-name='_ZN1SC1ERKS_' filepath='simple-class-0.C' line='18' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'>
|
|
<parameter type-id='type-id-4'/>
|
|
<parameter type-id='type-id-6'/>
|
|
<return type-id='type-id-5'/>
|
|
</function-decl>
|
|
</member-function>
|
|
</class-decl>
|
|
<reference-type-def kind='lvalue' type-id='type-id-2' size-in-bits='64' alignment-in-bits='64' id='type-id-7'/>
|
|
<pointer-type-def type-id='type-id-2' size-in-bits='64' alignment-in-bits='64' id='type-id-4'/>
|
|
<qualified-type-def type-id='type-id-2' const='yes' filepath='simple-class-0.C' line='5' column='8' id='type-id-8'/>
|
|
<reference-type-def kind='lvalue' type-id='type-id-8' size-in-bits='64' alignment-in-bits='64' id='type-id-6'/>
|
|
<function-decl name='foo' mangled-name='_Z3fooR1S' filepath='simple-class-0.C' line='24' column='1' visibility='default' binding='global' size-in-bits='8' alignment-in-bits='8'>
|
|
<parameter type-id='type-id-7'/>
|
|
<return type-id='type-id-5'/>
|
|
</function-decl>
|
|
<type-decl name='void' id='type-id-5'/>
|
|
</abi-instr>
|