public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Giuliano Procida <gprocida@google.com>
To: libabigail@sourceware.org
Cc: dodji@seketeli.org, kernel-team@android.com, gprocida@google.com,
	 maennich@google.com
Subject: [PATCH] XML writer: unify type emission tracking
Date: Fri,  3 Jun 2022 14:09:10 +0100	[thread overview]
Message-ID: <20220603130910.3039296-1-gprocida@google.com> (raw)

Empirically, the tracking of declaration-only type emission no longer
seems to make any difference. It is removed here.

	* src/abg-writer.cc (write_context): Remove the
	m_emitted_decl_only_set member.
	(write_context::has_non_emitted_referenced_types): Remove the
	calls to decl_only_type_is_emitted.
	(write_context::record_decl_only_type_as_emitted): Removed.
	(write_context::decl_only_type_is_emitted): Ditto.
	(write_context::get_emitted_decl_only_types_set): Ditto.
	(referenced_type_should_be_emitted): Remove the calls to
	decl_only_type_is_emitted.
	(write_class_decl): Just call record_type_as_emitted.
	(write_union_decl): Ditto.
	(write_enum_type_decl): Not changed, but now all 3 functions
	have the same behaviour.
	(write_canonical_type_ids): Remove the call to
	get_emitted_decl_only_types_set.

Signed-off-by: Giuliano Procida <gprocida@google.com>
---
 src/abg-writer.cc | 90 +++++------------------------------------------
 1 file changed, 8 insertions(+), 82 deletions(-)

diff --git a/src/abg-writer.cc b/src/abg-writer.cc
index 7802128d..3f50a900 100644
--- a/src/abg-writer.cc
+++ b/src/abg-writer.cc
@@ -143,7 +143,6 @@ class write_context
   mutable type_ptr_map			m_type_id_map;
   mutable unordered_set<uint32_t>	m_used_type_id_hashes;
   mutable type_ptr_set_type		m_emitted_type_set;
-  type_ptr_set_type			m_emitted_decl_only_set;
   // A map of types that are referenced by emitted pointers,
   // references or typedefs
   type_ptr_set_type			m_referenced_types_set;
@@ -491,18 +490,15 @@ public:
   has_non_emitted_referenced_types() const
   {
     for (const auto t : get_referenced_types())
-      if (!type_is_emitted(t)
-	  && !decl_only_type_is_emitted(t))
-	  return false;
+      if (!type_is_emitted(t))
+	return false;
 
     for (const auto t : get_referenced_non_canonical_types())
-      if (!type_is_emitted(t)
-	  && !decl_only_type_is_emitted(t))
-	  return false;
+      if (!type_is_emitted(t))
+	return false;
 
     for (const auto t : get_referenced_non_canonical_types())
-      if (!type_is_emitted(t)
-	  && !decl_only_type_is_emitted(t))
+      if (!type_is_emitted(t))
 	return false;
 
     return true;
@@ -741,55 +737,6 @@ public:
     return m_emitted_decls_set.find(irepr) != m_emitted_decls_set.end();
   }
 
-  /// Record a declaration-only class as being emitted.
-  ///
-  /// For now, this function expects a declaration-only class,
-  /// otherwise, it aborts.
-  ///
-  /// @param t the declaration-only class to report as emitted.
-  void
-  record_decl_only_type_as_emitted(type_base* t)
-  {
-    class_or_union* cl = is_class_or_union_type(t);
-    ABG_ASSERT(cl && cl->get_is_declaration_only());
-    m_emitted_decl_only_set.insert(t);
-  }
-
-  /// Record a declaration-only class as being emitted.
-  ///
-  /// For now, this function expects a declaration-only class,
-  /// otherwise, it aborts.
-  ///
-  /// @param t the declaration-only class to report as emitted.
-  void
-  record_decl_only_type_as_emitted(const type_base_sptr& t)
-  {record_decl_only_type_as_emitted(t.get());}
-
-  /// Test if a declaration-only class has been emitted.
-  ///
-  /// @param t the declaration-only class to test for.
-  ///
-  /// @return true iff the declaration-only class @p t has been
-  /// emitted.
-  bool
-  decl_only_type_is_emitted(const type_base* t) const
-  {
-    type_ptr_set_type::const_iterator i = m_emitted_decl_only_set.find(t);
-    if (i == m_emitted_decl_only_set.end())
-      return false;
-    return true;
-  }
-
-  /// Test if a declaration-only class has been emitted.
-  ///
-  /// @param t the declaration-only class to test for.
-  ///
-  /// @return true iff the declaration-only class @p t has been
-  /// emitted.
-  bool
-  decl_only_type_is_emitted(const type_base_sptr& t) const
-  {return decl_only_type_is_emitted(t.get());}
-
   /// Record a declaration as emitted in the abixml output.
   ///
   /// @param decl the decl to consider.
@@ -808,13 +755,6 @@ public:
   get_emitted_types_set() const
   {return m_emitted_type_set;}
 
-  /// Get the set of types that have been emitted.
-  ///
-  /// @return the set of types that have been emitted.
-  const type_ptr_set_type&
-  get_emitted_decl_only_types_set() const
-  {return m_emitted_decl_only_set;}
-
   /// Clear the map that contains the IDs of the types that has been
   /// recorded as having been written out to the XML output.
   void
@@ -2246,8 +2186,7 @@ referenced_type_should_be_emitted(const type_base *t,
   if ((tu_is_last || (t->get_translation_unit()
 		      && (t->get_translation_unit()->get_absolute_path()
 			  == tu.get_absolute_path())))
-      && !ctxt.type_is_emitted(t)
-      && !ctxt.decl_only_type_is_emitted(t))
+      && !ctxt.type_is_emitted(t))
     return true;
   return false;
 }
@@ -3845,12 +3784,7 @@ write_class_decl(const class_decl_sptr& d,
       o << "</class-decl>\n";
     }
 
-  // We allow several *declarations* of the same class in the corpus,
-  // but only one definition.
-  if (!decl->get_is_declaration_only())
-    ctxt.record_type_as_emitted(decl);
-  else
-    ctxt.record_decl_only_type_as_emitted(decl);
+  ctxt.record_type_as_emitted(decl);
 
   return true;
 }
@@ -4005,12 +3939,7 @@ write_union_decl(const union_decl_sptr& d,
       o << "</union-decl>\n";
     }
 
-  // We allow several *declarations* of the same union in the corpus,
-  // but only one definition.
-  if (!decl->get_is_declaration_only())
-    ctxt.record_type_as_emitted(decl);
-  else
-    ctxt.record_decl_only_type_as_emitted(decl);
+  ctxt.record_type_as_emitted(decl);
 
   return true;
 }
@@ -4848,9 +4777,6 @@ write_canonical_type_ids(xml_writer::write_context& ctxt, ostream& o)
   for (const auto &type : ctxt.get_emitted_types_set())
     write_type_record(ctxt, type, o);
 
-  for (const auto &type : ctxt.get_emitted_decl_only_types_set())
-    write_type_record(ctxt, type, o);
-
   o << "</abixml-types-check>\n";
 }
 
-- 
2.36.1.255.ge46751e96f-goog


             reply	other threads:[~2022-06-03 13:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-03 13:09 Giuliano Procida [this message]
2022-06-07 13:43 ` Dodji Seketeli

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=20220603130910.3039296-1-gprocida@google.com \
    --to=gprocida@google.com \
    --cc=dodji@seketeli.org \
    --cc=kernel-team@android.com \
    --cc=libabigail@sourceware.org \
    --cc=maennich@google.com \
    /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).