public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] ir: Add equality op to array_type_def::subrange_type::bound_value
@ 2020-11-24 10:21 Dodji Seketeli
  0 siblings, 0 replies; only message in thread
From: Dodji Seketeli @ 2020-11-24 10:21 UTC (permalink / raw)
  To: libabigail

Hello,

I noticed that array_type_def::subrange_type::bound_value didn't have an
equality operator.  Having one is useful in setting debugger breakpoints
to detect when bound values are being compared and analyse why.

This patch adds that operator.

	* include/abg-ir.h
	(array_type_def::subrange_type::bound_value::operator==): Declare
	new ...
	* src/abg-ir.cc
	(array_type_def::subrange_type::bound_value::operator==):
	... equality operator.

Signed-off-by: Dodji Seketeli <dodji@redhat.com>

Applied to master.
---
 include/abg-ir.h |  1 +
 src/abg-ir.cc    | 11 +++++++++++
 2 files changed, 12 insertions(+)

diff --git a/include/abg-ir.h b/include/abg-ir.h
index 9ca083c..dca0d12 100644
--- a/include/abg-ir.h
+++ b/include/abg-ir.h
@@ -2326,6 +2326,7 @@ public:
       uint64_t get_unsigned_value();
       void set_unsigned(uint64_t v);
       void set_signed(int64_t v);
+      bool operator==(const bound_value&) const;
     }; //end class bound_value
 
     /// Hasher for an instance of array::subrange
diff --git a/src/abg-ir.cc b/src/abg-ir.cc
index 516e34b..a78889a 100644
--- a/src/abg-ir.cc
+++ b/src/abg-ir.cc
@@ -14738,6 +14738,17 @@ array_type_def::subrange_type::bound_value::set_signed(int64_t v)
   v_.signed_ = v;
 }
 
+/// Equality operator of the bound value.
+///
+/// @param v the other bound value to compare with.
+///
+/// @return true iff the current bound value equals @p v.
+bool
+array_type_def::subrange_type::bound_value::operator==(const bound_value& v) const
+{
+  return s_ == v.s_ && v_.unsigned_ == v.v_.unsigned_;
+}
+
 // </array_type_def::subrante_type::bound_value>
 
 struct array_type_def::subrange_type::priv
-- 
1.8.3.1


-- 
		Dodji


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

only message in thread, other threads:[~2020-11-24 10:21 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-24 10:21 [PATCH] ir: Add equality op to array_type_def::subrange_type::bound_value 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).