[17/27] dwarf-reader: Fix building of void, void* and variadic parm types

Message ID 878qwfl3f2.fsf@seketeli.org
State New
Headers
Series Implement type hashing & fix self-comparing gcc-gnat in fc37 |

Commit Message

Dodji Seketeli Aug. 29, 2024, 4:06 p.m. UTC
  Hello,

This patch adds the IR nodes of void, void* and variadic parm types to
their scope just once.  Also, it schedules them for (sorting, hashing
and) canonicalization just like other types.

	* src/abg-dwarf-reader.cc (build_ir_node_for_void_type)
	(build_ir_node_for_void_pointer_type)
	(build_ir_node_for_variadic_parameter_type): Add the type node to
	its scope just once.  Use
	reader::schedule_type_for_late_canonicalization to canonicalize
	it.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 src/abg-dwarf-reader.cc | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)
  

Patch

diff --git a/src/abg-dwarf-reader.cc b/src/abg-dwarf-reader.cc
index 253e647d..bf33dc7c 100644
--- a/src/abg-dwarf-reader.cc
+++ b/src/abg-dwarf-reader.cc
@@ -17158,9 +17158,12 @@  build_ir_node_for_void_type(reader& rdr)
   const environment& env = rdr.env();
 
   type_base_sptr t = env.get_void_type();
-  add_decl_to_scope(is_decl(t), rdr.cur_transl_unit()->get_global_scope());
   decl_base_sptr type_declaration = get_type_declaration(t);
-  canonicalize(t);
+  if (!has_scope(type_declaration))
+    {
+      add_decl_to_scope(is_decl(t), rdr.cur_transl_unit()->get_global_scope());
+      rdr.schedule_type_for_late_canonicalization(t);
+    }
   return type_declaration;
 }
 
@@ -17179,11 +17182,13 @@  static type_or_decl_base_sptr
 build_ir_node_for_void_pointer_type(reader& rdr)
 {
   const environment& env = rdr.env();
-
   type_base_sptr t = env.get_void_pointer_type();
-  add_decl_to_scope(is_decl(t), rdr.cur_transl_unit()->get_global_scope());
   decl_base_sptr type_declaration = get_type_declaration(t);
-  canonicalize(t);
+  if (!has_scope(type_declaration))
+    {
+      add_decl_to_scope(is_decl(t), rdr.cur_transl_unit()->get_global_scope());
+      rdr.schedule_type_for_late_canonicalization(t);
+    }
   return type_declaration;
 }
 
@@ -17197,11 +17202,13 @@  build_ir_node_for_variadic_parameter_type(reader &rdr)
 {
 
   const environment& env = rdr.env();
-
   type_base_sptr t = env.get_variadic_parameter_type();
-  add_decl_to_scope(is_decl(t), rdr.cur_transl_unit()->get_global_scope());
   decl_base_sptr type_declaration = get_type_declaration(t);
-  canonicalize(t);
+  if (!has_scope(type_declaration))
+    {
+      add_decl_to_scope(is_decl(t), rdr.cur_transl_unit()->get_global_scope());
+      rdr.schedule_type_for_late_canonicalization(t);
+    }
   return type_declaration;
 }