* [PATCH, applied] ir: Fix cycle detection for union types
@ 2023-03-10 8:46 Dodji Seketeli
0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2023-03-10 8:46 UTC (permalink / raw)
To: libabigail
Hello,
It seems the commit below (in libabigail 2.1) broke the cycle
detection during union types comparison.
commit 4bc513a8ae4436625e8641125e0dd0d75d398af2
Author: Dodji Seketeli <dodji@redhat.com>
Date: Thu Sep 8 19:09:33 2022 +0200
Fix IR comparison result caching and canonical type propagation tracking
This patch fixes that.
* src/abg-ir.cc (CACHE_COMPARISON_RESULT_AND_RETURN): Define new
macro.
(equals): In the overload for unions, detect cycles right
away. Also, do not use mark_types_as_being_compared and
return_comparison_result as that would indirectly call
environment::priv::unmark_as_being_compared one too many, thus
breaking the cycle detection machinery. Rather, just cache the
result of comparing the type as a class_or_union and return, using
CACHE_COMPARISON_RESULT_AND_RETURN.
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.
---
src/abg-ir.cc | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 015aa2b3..047b755d 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -1104,6 +1104,18 @@ return_comparison_result(T& l, T& r, bool value,
l.get_environment().priv_->cache_type_comparison_result(l, r, res); \
return res; \
} while (false)
+
+/// Cache the result of a comparison between too artifacts (l & r) and
+/// return immediately.
+///
+/// @param value the value to cache.
+#define CACHE_COMPARISON_RESULT_AND_RETURN(value) \
+ do \
+ { \
+ l.get_environment().priv_->cache_type_comparison_result(l, r, value); \
+ return value; \
+ } while (false)
+
/// Getter of all types types sorted by their pretty representation.
///
/// @return a sorted vector of all types sorted by their pretty
@@ -24935,6 +24947,9 @@ union_decl::~union_decl()
bool
equals(const union_decl& l, const union_decl& r, change_kind* k)
{
+
+ RETURN_TRUE_IF_COMPARISON_CYCLE_DETECTED(l, r);
+
{
// First of all, let's see if these two types haven't already been
// compared. If so, and if the result of the comparison has been
@@ -24945,15 +24960,11 @@ equals(const union_decl& l, const union_decl& r, change_kind* k)
return result;
}
-#define RETURN(value) CACHE_AND_RETURN_COMPARISON_RESULT(value)
-
bool result = equals(static_cast<const class_or_union&>(l),
static_cast<const class_or_union&>(r),
k);
- mark_types_as_being_compared(l, r);
-
- RETURN(result);
+ CACHE_COMPARISON_RESULT_AND_RETURN(result);
}
/// Copy a method of a @ref union_decl into a new @ref
--
2.39.2
--
Dodji
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-03-10 8:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-10 8:46 [PATCH, applied] ir: Fix cycle detection for union 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).