[06/11] ir: Support comparing a class_decl against a class_or_union

Message ID 20240814125649.47119-6-dodji@redhat.com
State New
Headers
Series [01/11] Use smart pointers for variables exported from the ABI corpus |

Commit Message

Dodji Seketeli Aug. 14, 2024, 12:56 p.m. UTC
  From: Dodji Seketeli <dodji@redhat.com>

When a class_decl is compared against a class_or_union type using
class_decl::operator==, that operator systematically fails.  This
patch fixes that by comparing the common parts between the two
objects.

	* src/abg-ir.cc (class_decl::operator==): Support comparing
	against a class_or_union.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 src/abg-ir.cc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Patch

diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index d0f267be..0b9e8d48 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -25647,7 +25647,11 @@  class_decl::operator==(const decl_base& other) const
 {
   const class_decl* op = is_class_type(&other);
   if (!op)
-    return false;
+    {
+      if (class_or_union* cou = is_class_or_union_type(&other))
+	return class_or_union::operator==(*cou);
+      return false;
+    }
 
   // If this is a decl-only type (and thus with no canonical type),
   // use the canonical type of the definition, if any.