[applied] ir: Add missing virtual methods overloads

Message ID 875ybvt4ej.fsf@redhat.com
State New
Headers
Series [applied] ir: Add missing virtual methods overloads |

Commit Message

Dodji Seketeli Feb. 21, 2023, 3:38 p.m. UTC
  Hello,

Fedora Rawhide recently moved to GCC 13 and so its emitting new
warnings about libabigail's code base, and rightly so.

This patch thus adds some missing virtual method overloads that are
spotted by GCC 13.

	* include/abg-ir.h (type_decl::operator!=): Declare missing
	virtual overloads.
	(array_type_def::subrange_type::operator!=): Likewise.
	(template_decl::operator==): Likewise.
	(type_tparameter::operator==): Likewise.
	(class_decl::operator==): Likewise.
	(union_decl::operator==): Likewise.
	(member_class_template::operator==): Likewise.
	* src/abg-ir.cc (type_decl::operator!=)
	(array_type_def::subrange_type::operator!=)
	(class_decl::operator==, member_class_template::operator==)
	(union_decl::operator==, template_decl::operator==)
	(type_tparameter::operator==, type_tparameter::operator==)
	(template_tparameter::operator==): Define new virtual overloads.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>
Applied to master.
---
 include/abg-ir.h |  36 +++++++++-
 src/abg-ir.cc    | 176 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 211 insertions(+), 1 deletion(-)
  

Patch

diff --git a/include/abg-ir.h b/include/abg-ir.h
index 6f83cfb0..0ca8afcf 100644
--- a/include/abg-ir.h
+++ b/include/abg-ir.h
@@ -2094,7 +2094,14 @@  public:
   virtual bool
   operator==(const type_decl&) const;
 
-  bool operator!=(const type_decl&)const;
+  virtual bool
+  operator!=(const type_base&)const;
+
+  virtual bool
+  operator!=(const decl_base&)const;
+
+  virtual bool
+  operator!=(const type_decl&)const;
 
   virtual void
   get_qualified_name(interned_string& qualified_name,
@@ -2554,6 +2561,12 @@  public:
     bool
     operator==(const subrange_type& o) const;
 
+    bool
+    operator!=(const decl_base& o) const;
+
+    bool
+    operator!=(const type_base& o) const;
+
     bool
     operator!=(const subrange_type& o) const;
 
@@ -3438,6 +3451,9 @@  public:
   const std::list<template_parameter_sptr>&
   get_template_parameters() const;
 
+  virtual bool
+  operator==(const decl_base& o) const;
+
   virtual bool
   operator==(const template_decl& o) const;
 
@@ -3514,6 +3530,12 @@  public:
   virtual bool
   operator==(const type_base&) const;
 
+  virtual bool
+  operator==(const type_decl&) const;
+
+  virtual bool
+  operator==(const decl_base&) const;
+
   virtual bool
   operator==(const template_parameter&) const;
 
@@ -3592,6 +3614,9 @@  public:
   virtual bool
   operator==(const type_base&) const;
 
+  virtual bool
+  operator==(const decl_base&) const;
+
   virtual bool
   operator==(const template_parameter&) const;
 
@@ -4212,6 +4237,9 @@  public:
   virtual bool
   operator==(const type_base&) const;
 
+  virtual bool
+  operator==(const class_or_union&) const;
+
   virtual bool
   operator==(const class_decl&) const;
 
@@ -4383,6 +4411,9 @@  public:
   virtual bool
   operator==(const type_base&) const;
 
+  virtual bool
+  operator==(const class_or_union&) const;
+
   virtual bool
   operator==(const union_decl&) const;
 
@@ -4642,6 +4673,9 @@  public:
   virtual bool
   operator==(const member_base& o) const;
 
+  virtual bool
+  operator==(const decl_base&) const;
+
   virtual bool
   operator==(const member_class_template&) const;
 
diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index ff7573ea..321adbf5 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -15295,6 +15295,28 @@  type_decl::operator==(const type_decl& o) const
   return *this == other;
 }
 
+/// Return true if both types equals.
+///
+/// Note that this does not check the scopes of any of the types.
+///
+/// @param o the other type_decl to check against.
+///
+/// @return true iff the current isntance equals @p o
+bool
+type_decl::operator!=(const type_base&o)const
+{return !operator==(o);}
+
+/// Return true if both types equals.
+///
+/// Note that this does not check the scopes of any of the types.
+///
+/// @param o the other type_decl to check against.
+///
+/// @return true iff the current isntance equals @p o
+bool
+type_decl::operator!=(const decl_base&o)const
+{return !operator==(o);}
+
 /// Inequality operator.
 ///
 /// @param o the other type to compare against.
@@ -17376,6 +17398,26 @@  array_type_def::subrange_type::operator==(const subrange_type& o) const
   return operator==(t);
 }
 
+/// Equality operator.
+///
+/// @param o the other subrange to test against.
+///
+/// @return true iff @p o equals the current instance of
+/// array_type_def::subrange_type.
+bool
+array_type_def::subrange_type::operator!=(const decl_base& o) const
+{return !operator==(o);}
+
+/// Equality operator.
+///
+/// @param o the other subrange to test against.
+///
+/// @return true iff @p o equals the current instance of
+/// array_type_def::subrange_type.
+bool
+array_type_def::subrange_type::operator!=(const type_base& o) const
+{return !operator==(o);}
+
 /// Inequality operator.
 ///
 /// @param o the other subrange to test against.
@@ -23887,6 +23929,20 @@  class_decl::operator==(const type_base& other) const
   return *this == *o;
 }
 
+/// Equality operator for class_decl.
+///
+/// Re-uses the equality operator that takes a decl_base.
+///
+/// @param other the other class_decl to compare against.
+///
+/// @return true iff the current instance equals the other one.
+bool
+class_decl::operator==(const class_or_union& other) const
+{
+  const decl_base& o = other;
+  return *this == o;
+}
+
 /// Comparison operator for @ref class_decl.
 ///
 /// @param other the instance of @ref class_decl to compare against.
@@ -24240,6 +24296,19 @@  member_class_template::operator==(const member_base& other) const
     {return false;}
 }
 
+/// Equality operator of the the @ref member_class_template class.
+///
+/// @param other the other @ref member_class_template to compare against.
+///
+/// @return true iff the current instance equals @p other.
+bool
+member_class_template::operator==(const decl_base& other) const
+{
+  if (!decl_base::operator==(other))
+    return false;
+  return as_class_tdecl()->class_tdecl::operator==(other);
+}
+
 /// Comparison operator for the @ref member_class_template
 /// type.
 ///
@@ -24680,6 +24749,20 @@  union_decl::operator==(const type_base& other) const
   return *this == *o;
 }
 
+/// Equality operator for union_decl.
+///
+/// Re-uses the equality operator that takes a decl_base.
+///
+/// @param other the other union_decl to compare against.
+///
+/// @return true iff the current instance equals the other one.
+bool
+union_decl::operator==(const class_or_union&other) const
+{
+  const decl_base *o = dynamic_cast<const decl_base*>(&other);
+  return *this == *o;
+}
+
 /// Comparison operator for @ref union_decl.
 ///
 /// @param other the instance of @ref union_decl to compare against.
@@ -24937,6 +25020,20 @@  template_decl::template_decl(const environment& env,
 template_decl::~template_decl()
 {}
 
+/// Equality operator.
+///
+/// @param o the other instance to compare against.
+///
+/// @return true iff @p equals the current instance.
+bool
+template_decl::operator==(const decl_base& o) const
+{
+  const template_decl* other = dynamic_cast<const template_decl*>(&o);
+  if (!other)
+    return false;
+  return *this == *other;
+}
+
 /// Equality operator.
 ///
 /// @param o the other instance to compare against.
@@ -25092,6 +25189,11 @@  type_tparameter::type_tparameter(unsigned		index,
   runtime_type_instance(this);
 }
 
+/// Equality operator.
+///
+/// @param other the other template type parameter to compare against.
+///
+/// @return true iff @p other equals the current instance.
 bool
 type_tparameter::operator==(const type_base& other) const
 {
@@ -25107,6 +25209,51 @@  type_tparameter::operator==(const type_base& other) const
     {return false;}
 }
 
+/// Equality operator.
+///
+/// @param other the other template type parameter to compare against.
+///
+/// @return true iff @p other equals the current instance.
+bool
+type_tparameter::operator==(const type_decl& other) const
+{
+  if (!type_decl::operator==(other))
+    return false;
+
+  try
+    {
+      const type_tparameter& o = dynamic_cast<const type_tparameter&>(other);
+      return template_parameter::operator==(o);
+    }
+  catch (...)
+    {return false;}
+}
+
+/// Equality operator.
+///
+/// @param other the other template type parameter to compare against.
+///
+/// @return true iff @p other equals the current instance.
+bool
+type_tparameter::operator==(const decl_base& other) const
+{
+  if (!decl_base::operator==(other))
+    return false;
+
+  try
+    {
+      const type_tparameter& o = dynamic_cast<const type_tparameter&>(other);
+      return template_parameter::operator==(o);
+    }
+  catch (...)
+    {return false;}
+}
+
+/// Equality operator.
+///
+/// @param other the other template type parameter to compare against.
+///
+/// @return true iff @p other equals the current instance.
 bool
 type_tparameter::operator==(const template_parameter& other) const
 {
@@ -25119,6 +25266,11 @@  type_tparameter::operator==(const template_parameter& other) const
     {return false;}
 }
 
+/// Equality operator.
+///
+/// @param other the other template type parameter to compare against.
+///
+/// @return true iff @p other equals the current instance.
 bool
 type_tparameter::operator==(const type_tparameter& other) const
 {return *this == static_cast<const type_base&>(other);}
@@ -25253,6 +25405,11 @@  template_tparameter::template_tparameter(unsigned		index,
   runtime_type_instance(this);
 }
 
+/// Equality operator.
+///
+/// @param other the other template parameter to compare against.
+///
+/// @return true iff @p other equals the current instance.
 bool
 template_tparameter::operator==(const type_base& other) const
 {
@@ -25267,6 +25424,25 @@  template_tparameter::operator==(const type_base& other) const
     {return false;}
 }
 
+/// Equality operator.
+///
+/// @param other the other template parameter to compare against.
+///
+/// @return true iff @p other equals the current instance.
+bool
+template_tparameter::operator==(const decl_base& other) const
+{
+  try
+    {
+      const template_tparameter& o =
+	dynamic_cast<const template_tparameter&>(other);
+      return (type_tparameter::operator==(o)
+	      && template_decl::operator==(o));
+    }
+  catch(...)
+    {return false;}
+}
+
 bool
 template_tparameter::operator==(const template_parameter& o) const
 {