public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Dodji Seketeli <dodji@redhat.com>
To: libabigail@sourceware.org
Subject: [PATCH, applied] reader: Build array types with their element type "a priori"
Date: Tue, 07 Dec 2021 18:45:03 +0100	[thread overview]
Message-ID: <871r2os40w.fsf@redhat.com> (raw)

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


                 reply	other threads:[~2021-12-07 17:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=871r2os40w.fsf@redhat.com \
    --to=dodji@redhat.com \
    --cc=libabigail@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).