]> sourceware.org Git - libabigail.git/commitdiff
ir, test-read-ctf: Remove uncertainty in sorting anonymous types
authorDodji Seketeli <dodji@redhat.com>
Mon, 13 Jun 2022 13:45:01 +0000 (15:45 +0200)
committerDodji Seketeli <dodji@redhat.com>
Mon, 13 Jun 2022 16:04:17 +0000 (18:04 +0200)
For a reason, I am seeing changes in the test-read-ctf output.  Those
are related to sorting anonymous structs that have no (internal) name.
The CTF reader emits such types.

This patch thus considers the flat representation of an anonymous
class/union when it doesn't have an internal name.  The patch also
updates the test-read-ctf output tests accordingly.

* src/abg-ir.cc ({class_decl,
union_decl}::get_pretty_representation): If the anonymous class
has no internal name, use its flat representation as internal
representation.
* tests/data/test-read-ctf/test-PR26568-1.o.abi: Likewise.
* tests/data/test-read-ctf/test-PR26568-2.o.abi: Likewise.
* tests/data/test-read-ctf/test-anonymous-fields.o.abi: Likewise.
* tests/data/test-read-ctf/test-anonymous-fields.o.abi: Likewise.
* tests/data/test-read-ctf/test0.hash.abi: Likewise.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
src/abg-ir.cc
tests/data/test-read-ctf/test-PR26568-1.o.abi
tests/data/test-read-ctf/test-PR26568-2.o.abi
tests/data/test-read-ctf/test-anonymous-fields.o.abi
tests/data/test-read-ctf/test0.hash.abi

index 4e907620ed577ec45fbde6f41ff1aa8dcf5f40a3..717c195d6912982b6f35032b5d33584c26c06d3f 100644 (file)
@@ -22119,7 +22119,7 @@ class_decl::get_pretty_representation(bool internal,
   // it has a name, which is the typedef name.
   if (get_is_anonymous())
     {
-      if (internal)
+      if (internal && !get_name().empty())
        return cl + get_type_name(this, qualified_name, /*internal=*/true);
       return get_class_or_union_flat_representation(this, "",
                                                    /*one_line=*/true,
@@ -23929,7 +23929,7 @@ union_decl::get_pretty_representation(bool internal,
   string repr;
   if (get_is_anonymous())
     {
-      if (internal)
+      if (internal && !get_name().empty())
        repr = string("union ") +
          get_type_name(this, qualified_name, /*internal=*/true);
       else
index 832dc1bdcdce8e893162b39883c5a8bf0c3b4b28..1b19fd9a4b3c5181a59bae4625515c921a549240 100644 (file)
@@ -8,24 +8,24 @@
         <var-decl name='' type-id='type-id-2' visibility='default'/>
       </data-member>
     </class-decl>
-    <class-decl name='' size-in-bits='64' alignment-in-bits='64' is-struct='yes' is-anonymous='yes' visibility='default' id='type-id-3'>
+    <class-decl name='' size-in-bits='32' alignment-in-bits='32' is-struct='yes' is-anonymous='yes' visibility='default' id='type-id-3'>
       <data-member access='public' layout-offset-in-bits='0'>
-        <var-decl name='y' type-id='type-id-4' visibility='default'/>
+        <var-decl name='x' type-id='type-id-4' visibility='default'/>
       </data-member>
     </class-decl>
-    <class-decl name='' size-in-bits='32' alignment-in-bits='32' is-struct='yes' is-anonymous='yes' visibility='default' id='type-id-5'>
+    <class-decl name='' size-in-bits='64' alignment-in-bits='64' is-struct='yes' is-anonymous='yes' visibility='default' id='type-id-5'>
       <data-member access='public' layout-offset-in-bits='0'>
-        <var-decl name='x' type-id='type-id-6' visibility='default'/>
+        <var-decl name='y' type-id='type-id-6' visibility='default'/>
       </data-member>
     </class-decl>
-    <type-decl name='int' size-in-bits='32' alignment-in-bits='32' id='type-id-6'/>
-    <type-decl name='long int' size-in-bits='64' alignment-in-bits='64' id='type-id-4'/>
+    <type-decl name='int' size-in-bits='32' alignment-in-bits='32' id='type-id-4'/>
+    <type-decl name='long int' size-in-bits='64' alignment-in-bits='64' id='type-id-6'/>
     <union-decl name='' size-in-bits='64' is-anonymous='yes' visibility='default' id='type-id-2'>
       <data-member access='public'>
-        <var-decl name='' type-id='type-id-5' visibility='default'/>
+        <var-decl name='' type-id='type-id-3' visibility='default'/>
       </data-member>
       <data-member access='public'>
-        <var-decl name='' type-id='type-id-3' visibility='default'/>
+        <var-decl name='' type-id='type-id-5' visibility='default'/>
       </data-member>
     </union-decl>
     <pointer-type-def type-id='type-id-1' size-in-bits='64' alignment-in-bits='64' id='type-id-7'/>
index 70e0772f0ee49db6091aacc7c2f8c6f955e50212..c6f3fbbb9a121e6c139652f8d3b0327a94e1b450 100644 (file)
@@ -3,24 +3,24 @@
     <elf-symbol name='fun' type='func-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
   </elf-function-symbols>
   <abi-instr address-size='64' language='LANG_C'>
-    <class-decl name='' size-in-bits='64' alignment-in-bits='64' is-struct='yes' is-anonymous='yes' visibility='default' id='type-id-1'>
+    <class-decl name='' size-in-bits='32' alignment-in-bits='32' is-struct='yes' is-anonymous='yes' visibility='default' id='type-id-1'>
       <data-member access='public' layout-offset-in-bits='0'>
-        <var-decl name='y' type-id='type-id-2' visibility='default'/>
+        <var-decl name='x' type-id='type-id-2' visibility='default'/>
       </data-member>
     </class-decl>
-    <class-decl name='' size-in-bits='32' alignment-in-bits='32' is-struct='yes' is-anonymous='yes' visibility='default' id='type-id-3'>
+    <class-decl name='' size-in-bits='64' alignment-in-bits='64' is-struct='yes' is-anonymous='yes' visibility='default' id='type-id-3'>
       <data-member access='public' layout-offset-in-bits='0'>
-        <var-decl name='x' type-id='type-id-4' visibility='default'/>
+        <var-decl name='y' type-id='type-id-4' visibility='default'/>
       </data-member>
     </class-decl>
-    <type-decl name='int' size-in-bits='32' alignment-in-bits='32' id='type-id-4'/>
-    <type-decl name='long int' size-in-bits='64' alignment-in-bits='64' id='type-id-2'/>
+    <type-decl name='int' size-in-bits='32' alignment-in-bits='32' id='type-id-2'/>
+    <type-decl name='long int' size-in-bits='64' alignment-in-bits='64' id='type-id-4'/>
     <union-decl name='A' size-in-bits='64' visibility='default' id='type-id-5'>
       <data-member access='public'>
-        <var-decl name='' type-id='type-id-3' visibility='default'/>
+        <var-decl name='' type-id='type-id-1' visibility='default'/>
       </data-member>
       <data-member access='public'>
-        <var-decl name='' type-id='type-id-1' visibility='default'/>
+        <var-decl name='' type-id='type-id-3' visibility='default'/>
       </data-member>
     </union-decl>
     <pointer-type-def type-id='type-id-5' size-in-bits='64' alignment-in-bits='64' id='type-id-6'/>
index 2134a86da982aae486947752b983da044ec57196..783b69826d18f5f24c417467b9836b470bc5a473 100644 (file)
@@ -3,31 +3,31 @@
     <elf-symbol name='t' size='8' type='object-type' binding='global-binding' visibility='default-visibility' is-defined='yes'/>
   </elf-variable-symbols>
   <abi-instr address-size='64' language='LANG_C'>
-    <class-decl name='' size-in-bits='32' alignment-in-bits='32' is-struct='yes' is-anonymous='yes' visibility='default' id='type-id-1'>
+    <class-decl name='uprobe_task' size-in-bits='64' alignment-in-bits='64' is-struct='yes' visibility='default' id='type-id-1'>
       <data-member access='public' layout-offset-in-bits='0'>
-        <var-decl name='dup_xol_work' type-id='type-id-2' visibility='default'/>
+        <var-decl name='' type-id='type-id-2' visibility='default'/>
       </data-member>
     </class-decl>
-    <class-decl name='' size-in-bits='64' alignment-in-bits='64' is-struct='yes' is-anonymous='yes' visibility='default' id='type-id-3'>
+    <class-decl name='' size-in-bits='32' alignment-in-bits='32' is-struct='yes' is-anonymous='yes' visibility='default' id='type-id-3'>
       <data-member access='public' layout-offset-in-bits='0'>
-        <var-decl name='vaddr' type-id='type-id-4' visibility='default'/>
+        <var-decl name='dup_xol_work' type-id='type-id-4' visibility='default'/>
       </data-member>
     </class-decl>
-    <class-decl name='uprobe_task' size-in-bits='64' alignment-in-bits='64' is-struct='yes' visibility='default' id='type-id-5'>
+    <class-decl name='' size-in-bits='64' alignment-in-bits='64' is-struct='yes' is-anonymous='yes' visibility='default' id='type-id-5'>
       <data-member access='public' layout-offset-in-bits='0'>
-        <var-decl name='' type-id='type-id-6' visibility='default'/>
+        <var-decl name='vaddr' type-id='type-id-6' visibility='default'/>
       </data-member>
     </class-decl>
-    <type-decl name='int' size-in-bits='32' alignment-in-bits='32' id='type-id-2'/>
-    <union-decl name='' size-in-bits='64' is-anonymous='yes' visibility='default' id='type-id-6'>
+    <type-decl name='int' size-in-bits='32' alignment-in-bits='32' id='type-id-4'/>
+    <union-decl name='' size-in-bits='64' is-anonymous='yes' visibility='default' id='type-id-2'>
       <data-member access='public'>
-        <var-decl name='' type-id='type-id-3' visibility='default'/>
+        <var-decl name='' type-id='type-id-5' visibility='default'/>
       </data-member>
       <data-member access='public'>
-        <var-decl name='' type-id='type-id-1' visibility='default'/>
+        <var-decl name='' type-id='type-id-3' visibility='default'/>
       </data-member>
     </union-decl>
-    <type-decl name='unsigned long int' size-in-bits='64' alignment-in-bits='64' id='type-id-4'/>
-    <var-decl name='t' type-id='type-id-5' mangled-name='t' visibility='default' elf-symbol-id='t'/>
+    <type-decl name='unsigned long int' size-in-bits='64' alignment-in-bits='64' id='type-id-6'/>
+    <var-decl name='t' type-id='type-id-1' mangled-name='t' visibility='default' elf-symbol-id='t'/>
   </abi-instr>
 </abi-corpus>
index eff322286b34269bc3967f5d12935d6bf71601aa..fa1daebc0ecf3467acde2db3ac547b868c71b6e1 100644 (file)
@@ -24,7 +24,7 @@
         <var-decl name='m0' type-id='95e97e5e' visibility='default'/>
       </data-member>
     </class-decl>
-    <class-decl name='' size-in-bits='32' alignment-in-bits='8' is-struct='yes' is-anonymous='yes' visibility='default' id='e7f43f72'>
+    <class-decl name='' size-in-bits='32' alignment-in-bits='8' is-struct='yes' is-anonymous='yes' visibility='default' id='b91ffdee'>
       <data-member access='public' layout-offset-in-bits='0'>
         <var-decl name='status0' type-id='811c9dc5' visibility='default'/>
       </data-member>
@@ -46,7 +46,7 @@
     <pointer-type-def type-id='bd54fe1a' size-in-bits='64' alignment-in-bits='64' id='3ccc2590'/>
     <qualified-type-def type-id='3ccc2590' restrict='yes' id='af4b1b38'/>
     <qualified-type-def type-id='a2185560' volatile='yes' id='ec67e496'/>
-    <var-decl name='status' type-id='e7f43f72' mangled-name='status' visibility='default' elf-symbol-id='status'/>
+    <var-decl name='status' type-id='b91ffdee' mangled-name='status' visibility='default' elf-symbol-id='status'/>
     <var-decl name='test_pointer' type-id='26a90f95' mangled-name='test_pointer' visibility='default' elf-symbol-id='test_pointer'/>
     <var-decl name='test_const' type-id='0fb3b55d' mangled-name='test_const' visibility='default' elf-symbol-id='test_const'/>
     <var-decl name='test_float' type-id='a6c45d85' mangled-name='test_float' visibility='default' elf-symbol-id='test_float'/>
This page took 0.483651 seconds and 5 git commands to generate.