public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, applied] reader: Build array types with their element type "a priori"
@ 2021-12-07 17:45 Dodji Seketeli
  0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2021-12-07 17:45 UTC (permalink / raw)
  To: libabigail

Hello,

In some ancient settings, we were building array types with no element
type set, then, when we have the element type built, we'd set it to
the array type.  This was to avoid looping indefinitely in cases where
the element type would indirectly depend on the array type itself.
Since then, we've built infrastructure to avoid those loops.

So we don't need those 'temporarily empty arrays' anymore.  Besides,
trying get the pretty representation of a variable declaration which
type is one of those temporarily empty arrays crashes because that
code doesn't expect empty arrays.

This patch sets the element type at array type building type now.  The
code also asserts that element types of arrays are not empty, in the
pretty representation of variable declarations.

	* src/abg-ir.cc (var_decl::get_pretty_representation): Assert that
	array element types are not empty.
	* src/abg-reader.cc (build_array_type_def): Set array element
	types a priori.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.
---
 src/abg-ir.cc     |  7 +++++--
 src/abg-reader.cc | 12 +++++-------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 2cc4cf8c..03b38c3a 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -18497,8 +18497,11 @@ var_decl::get_pretty_representation(bool internal, bool qualified_name) const
       else
 	name = get_qualified_name(internal);
 
-      result +=
-	get_type_declaration(t->get_element_type())->get_qualified_name(internal)
+      type_base_sptr et = t->get_element_type();
+      ABG_ASSERT(et);
+      decl_base_sptr decl = get_type_declaration(et);
+      ABG_ASSERT(decl);
+      result += decl->get_qualified_name(internal)
 	+ " " + name + t->get_subrange_representation();
     }
   else
diff --git a/src/abg-reader.cc b/src/abg-reader.cc
index bf08b2e7..541ca179 100644
--- a/src/abg-reader.cc
+++ b/src/abg-reader.cc
@@ -4282,17 +4282,15 @@ build_array_type_def(read_context&	ctxt,
 	  }
       }
 
-  array_type_def_sptr ar_type(new array_type_def(ctxt.get_environment(),
-						 subranges, loc));
-  maybe_set_artificial_location(ctxt, node, ar_type);
-  if (ctxt.push_and_key_type_decl(ar_type, id, add_to_current_scope))
-    ctxt.map_xml_node_to_decl(node, ar_type);
-
   // The type of array elements.
   type_base_sptr type =
     ctxt.build_or_get_type_decl(type_id, true);
   ABG_ASSERT(type);
-  ar_type->set_element_type(type);
+
+  array_type_def_sptr ar_type(new array_type_def(type, subranges, loc));
+  maybe_set_artificial_location(ctxt, node, ar_type);
+  if (ctxt.push_and_key_type_decl(ar_type, id, add_to_current_scope))
+    ctxt.map_xml_node_to_decl(node, ar_type);
 
   if (dimensions != ar_type->get_dimension_count()
       || (alignment_in_bits
-- 
2.33.1


-- 
		Dodji


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-07 17:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-07 17:45 [PATCH, applied] reader: Build array types with their element type "a priori" Dodji Seketeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).