[applied] ir: Fix cycle detection for union types
Commit Message
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(-)
@@ -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