public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH, applied] ir: Make IR node visitor aware of non-canonicalized types
@ 2024-05-03 21:19 Dodji Seketeli
  0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2024-05-03 21:19 UTC (permalink / raw)
  To: libabigail; +Cc: ckalina

Hello,

is_non_canonicalized_type is the function that decides which type
should be canonicalized or not.  So, code that expects a type to be
canonicalized should comply with the rule of
is_non_canonicalized_type, aka The Rule.  It turns out, the IR node
visitor code fails to comply with The Rule.  Fixed thus.  Note that
with this commit, the program build/tests/testirwalker now works fine
on itself.  Many thanks to Cestmir Kalina who noticed and reported the
issue.

	* src/abg-ir.cc (ir_node_visitor::{mark_type_node_as_visited,
	type_node_has_been_visited}): Invoke is_non_canonicalized_type to
	know if we should expect a type to have a canonical type or not.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to the master branch.
---
 src/abg-ir.cc | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index bb0ac6d4..d0ce6900 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -29380,7 +29380,12 @@ ir_node_visitor::mark_type_node_as_visited(type_base *p)
     return;
 
   type_base* canonical_type = p->get_naked_canonical_type();
-  ABG_ASSERT(canonical_type);
+  if (is_non_canonicalized_type(p))
+    {
+      ABG_ASSERT(!canonical_type);
+      canonical_type = p;
+    }
+    ABG_ASSERT(canonical_type);
 
   size_t canonical_ptr_value = reinterpret_cast<size_t>(canonical_type);
   priv_->visited_ir_nodes.insert(canonical_ptr_value);
@@ -29414,6 +29419,11 @@ ir_node_visitor::type_node_has_been_visited(type_base* p) const
     return false;
 
   type_base *canonical_type = p->get_naked_canonical_type();
+  if (is_non_canonicalized_type(p))
+    {
+      ABG_ASSERT(!canonical_type);
+      canonical_type = p;
+    }
   ABG_ASSERT(canonical_type);
 
   size_t ptr_value = reinterpret_cast<size_t>(canonical_type);
-- 
2.39.3


-- 
		Dodji


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

only message in thread, other threads:[~2024-05-03 21:20 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-03 21:19 [PATCH, applied] ir: Make IR node visitor aware of non-canonicalized types 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).