public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Sergio Durigan Junior <sergiodj@redhat.com>
To: GDB Patches <gdb-patches@sourceware.org>
Cc: Simon Marchi <simon.marchi@polymtl.ca>,
	Pedro Alves <palves@redhat.com>,
	Sergio Durigan Junior <sergiodj@redhat.com>
Subject: [PATCH] Remove relational operators from common/offset-type.h
Date: Mon, 29 Oct 2018 21:14:00 -0000	[thread overview]
Message-ID: <20181029211401.21602-1-sergiodj@redhat.com> (raw)
In-Reply-To: <20181025211008.12164-1-sergiodj@redhat.com>

This patch is a follow-up of:

  https://sourceware.org/ml/gdb-patches/2018-10/msg00601.html

It removes the declaration of the relational operators for
common/offset-type.h.  As it turns out, these overloads are not being
used when a new offset type is declared, because, according to Pedro
Alves:

  I think the functions aren't called because they are templates, and
  thus the built-in (non-template) versions take precedence.  If you
  make them non-templates, then they should be called.  But, the
  built-ins are fine, so yeah, we can just remove the custom
  definitions.

The patch also adjusts the comments on the code.

No regressions introduced.

gdb/ChangeLog:
2018-10-29  Sergio Durigan Junior  <sergiodj@redhat.com>

	* common/offset-type.h (DEFINE_OFFSET_REL_OP): Delete.
	Adjust comments.
---
 gdb/ChangeLog            |  5 +++++
 gdb/common/offset-type.h | 18 +-----------------
 2 files changed, 6 insertions(+), 17 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 1cba619fd9..6fb02d26ea 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2018-10-29  Sergio Durigan Junior  <sergiodj@redhat.com>
+
+	* common/offset-type.h (DEFINE_OFFSET_REL_OP): Delete.
+	Adjust comments.
+
 2018-10-29  Rainer Orth  <ro@CeBiTec.Uni-Bielefeld.DE>
 
 	* procfs.c: Include common/pathstuff.h.
diff --git a/gdb/common/offset-type.h b/gdb/common/offset-type.h
index b480b14406..174ad1e456 100644
--- a/gdb/common/offset-type.h
+++ b/gdb/common/offset-type.h
@@ -57,7 +57,7 @@
 /* The macro macro is all you need to know use offset types.  The rest
    below is all implementation detail.  */
 
-/* For each enum class type that you want to support relational
+/* For each enum class type that you want to support arithmetic
    operators, declare an "is_offset_type" overload that has exactly
    one parameter, of type that enum class.  E.g.,:
 
@@ -73,22 +73,6 @@
    function via ADL.
 */
 
-#define DEFINE_OFFSET_REL_OP(OP)					\
-  template<typename E,							\
-	   typename = decltype (is_offset_type (std::declval<E> ()))>	\
-  constexpr bool							\
-  operator OP (E lhs, E rhs)						\
-  {									\
-    using underlying = typename std::underlying_type<E>::type;		\
-    return (static_cast<underlying> (lhs)				\
-	    OP static_cast<underlying> (lhs));				\
-  }
-
-DEFINE_OFFSET_REL_OP(>)
-DEFINE_OFFSET_REL_OP(>=)
-DEFINE_OFFSET_REL_OP(<)
-DEFINE_OFFSET_REL_OP(<=)
-
 /* Adding or subtracting an integer to an offset type shifts the
    offset.  This is like "PTR = PTR + INT" and "PTR += INT".  */
 
-- 
2.17.1

  parent reply	other threads:[~2018-10-29 21:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-25 21:10 [PATCH] Fix thinko on common/offset-type.h (compare 'lhs' against 'rhs') Sergio Durigan Junior
2018-10-26  4:03 ` Kevin Buettner
2018-10-26 16:30   ` Sergio Durigan Junior
2018-10-26 16:08 ` Simon Marchi
2018-10-26 16:29   ` Sergio Durigan Junior
2018-10-26 18:23     ` Simon Marchi
2018-10-29 20:11       ` Pedro Alves
2018-10-29 20:14         ` Pedro Alves
2018-10-29 21:14 ` Sergio Durigan Junior [this message]
2018-10-30  3:17   ` [PATCH] Remove relational operators from common/offset-type.h Simon Marchi
2018-10-30  3:49     ` Sergio Durigan Junior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181029211401.21602-1-sergiodj@redhat.com \
    --to=sergiodj@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@redhat.com \
    --cc=simon.marchi@polymtl.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).