From patchwork Mon Oct 29 21:14:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Durigan Junior X-Patchwork-Id: 29954 Received: (qmail 18362 invoked by alias); 29 Oct 2018 21:14:11 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 18348 invoked by uid 89); 29 Oct 2018 21:14:10 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=sergiodj@redhat.com, U*sergiodj, sergiodjredhatcom, sk:sergiod X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 29 Oct 2018 21:14:08 +0000 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7195589AD5; Mon, 29 Oct 2018 21:14:07 +0000 (UTC) Received: from psique.yyz.redhat.com (unused-10-15-17-196.yyz.redhat.com [10.15.17.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43933600C5; Mon, 29 Oct 2018 21:14:02 +0000 (UTC) From: Sergio Durigan Junior To: GDB Patches Cc: Simon Marchi , Pedro Alves , Sergio Durigan Junior Subject: [PATCH] Remove relational operators from common/offset-type.h Date: Mon, 29 Oct 2018 17:14:01 -0400 Message-Id: <20181029211401.21602-1-sergiodj@redhat.com> In-Reply-To: <20181025211008.12164-1-sergiodj@redhat.com> References: <20181025211008.12164-1-sergiodj@redhat.com> X-IsSubscribed: yes 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 * 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 + + * common/offset-type.h (DEFINE_OFFSET_REL_OP): Delete. + Adjust comments. + 2018-10-29 Rainer Orth * 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 ()))> \ - constexpr bool \ - operator OP (E lhs, E rhs) \ - { \ - using underlying = typename std::underlying_type::type; \ - return (static_cast (lhs) \ - OP static_cast (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". */