From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26104 invoked by alias); 16 Mar 2016 22:19:17 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Received: (qmail 26087 invoked by uid 89); 16 Mar 2016 22:19:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=denotes, 4217, 4399, HContent-Transfer-Encoding:8bit 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 (AES256-GCM-SHA384 encrypted) ESMTPS; Wed, 16 Mar 2016 22:19:15 +0000 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id 7C9B8711C6; Wed, 16 Mar 2016 22:19:14 +0000 (UTC) Received: from valrhona.uglyboxes.com (ovpn01.gateway.prod.ext.phx2.redhat.com [10.5.9.1]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u2GMJDoV011708 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 16 Mar 2016 18:19:14 -0400 From: Keith Seitz Subject: Re: [PATCH v3 02/11] [PR gdb/14441] gdb: gdbtypes: change {lookup,make}_reference_type() API To: Artemiy Volkov , gdb-patches@sourceware.org References: <1453229609-20159-1-git-send-email-artemiyv@acm.org> <1457147955-21871-1-git-send-email-artemiyv@acm.org> <1457147955-21871-3-git-send-email-artemiyv@acm.org> Message-ID: <56E9DBE1.10408@redhat.com> Date: Wed, 16 Mar 2016 22:19:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 MIME-Version: 1.0 In-Reply-To: <1457147955-21871-3-git-send-email-artemiyv@acm.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-IsSubscribed: yes X-SW-Source: 2016-03/txt/msg00272.txt.bz2 On 03/04/2016 07:19 PM, Artemiy Volkov wrote: > Parameterize lookup_reference_type() and make_reference_type() by the kind of > reference type we want to look up. Create two wrapper functions > lookup_{lvalue,rvalue}_reference_type() for lookup_reference_type() to simplify > the API. Change all callers to use the new API. Just an FYI: When the time comes to commit this, GIT will require a single-line description/summary of the patch, followed by a blank line. > diff --git a/gdb/gdbtypes.c b/gdb/gdbtypes.c > index f129b0e..a99e878 100644 > --- a/gdb/gdbtypes.c > +++ b/gdb/gdbtypes.c > @@ -384,15 +384,21 @@ lookup_pointer_type (struct type *type) > /* Lookup a C++ `reference' to a type TYPE. TYPEPTR, if nonzero, > points to a pointer to memory where the reference type should be > stored. If *TYPEPTR is zero, update it to point to the reference > - type we return. We allocate new memory if needed. */ > + type we return. We allocate new memory if needed. REFCODE denotes Need two spaces after "if needed." > + the kind of reference type to lookup (lvalue or rvalue reference). */ > > struct type * > -make_reference_type (struct type *type, struct type **typeptr) > +make_reference_type (struct type *type, struct type **typeptr, > + enum type_code refcode) > { > struct type *ntype; /* New type */ > + struct type **reftype; > struct type *chain; > > - ntype = TYPE_REFERENCE_TYPE (type); > + gdb_assert (refcode == TYPE_CODE_REF || refcode == TYPE_CODE_RVALUE_REF); > + > + ntype = (refcode == TYPE_CODE_REF ? TYPE_REFERENCE_TYPE (type) > + : TYPE_RVALUE_REFERENCE_TYPE (type)); > > if (ntype) > { > @@ -421,7 +427,11 @@ make_reference_type (struct type *type, struct type **typeptr) > } > > TYPE_TARGET_TYPE (ntype) = type; > - TYPE_REFERENCE_TYPE (type) = ntype; > + reftype = (refcode == TYPE_CODE_REF ? &TYPE_REFERENCE_TYPE (type) > + : &TYPE_RVALUE_REFERENCE_TYPE (type)); > + > + if(*reftype != NULL) > + *reftype = ntype; > > /* FIXME! Assume the machine has only one representation for > references, and that it matches the (only) representation for I would prefer to do: if (refcode == TYPE_CODE_REF) TYPE_REFERENCE_TYPE (type) = ntype; else TYPE_RVALUE_REFERENCE_TYPE (type) = ntype; It's cleaner/smaller/easier to read (at least for me). [Otherwise, a space is missing between "if" and "(".] See next comment, though. > @@ -429,10 +439,9 @@ make_reference_type (struct type *type, struct type **typeptr) > > TYPE_LENGTH (ntype) = > gdbarch_ptr_bit (get_type_arch (type)) / TARGET_CHAR_BIT; > - TYPE_CODE (ntype) = TYPE_CODE_REF; > + TYPE_CODE (ntype) = refcode; > > - if (!TYPE_REFERENCE_TYPE (type)) /* Remember it, if don't have one. */ > - TYPE_REFERENCE_TYPE (type) = ntype; > + *reftype = ntype; > This is slightly different from the original, which only set the new type if it was unset in the type. Your revised version will unconditionally do it every time. I have no idea if it makes a difference or not. Do you? > /* Update the length of all the other variants of this type. */ > chain = TYPE_CHAIN (ntype); Keith