From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 41556 invoked by alias); 18 Oct 2017 11:20:00 -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 41049 invoked by uid 89); 18 Oct 2017 11:19:59 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.9 required=5.0 tests=BAYES_00,KAM_LAZY_DOMAIN_SECURITY,RP_MATCHES_RCVD,SPF_HELO_PASS autolearn=no version=3.3.2 spammy=Hx-languages-length:1904 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; Wed, 18 Oct 2017 11:19:58 +0000 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 875B2154B7C for ; Wed, 18 Oct 2017 11:19:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 875B2154B7C Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=palves@redhat.com Received: from [127.0.0.1] (ovpn04.gateway.prod.ext.ams2.redhat.com [10.39.146.4]) by smtp.corp.redhat.com (Postfix) with ESMTP id E038F6D816; Wed, 18 Oct 2017 11:19:56 +0000 (UTC) Subject: Re: [PATCH] Canonicalize conversion operators To: Keith Seitz , gdb-patches@sourceware.org References: <1508278336-8655-1-git-send-email-keiths@redhat.com> From: Pedro Alves Message-ID: <9b6b1fae-ea57-f5ac-da59-59c7a94b236c@redhat.com> Date: Wed, 18 Oct 2017 11:20:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <1508278336-8655-1-git-send-email-keiths@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SW-Source: 2017-10/txt/msg00559.txt.bz2 On 10/17/2017 11:12 PM, Keith Seitz wrote: > Consider a conversion operator such as: > > operator foo const* const* (); > > There are two small parser problems, highlighted by this test: > > (gdb) p operator foo const* const* > There is no field named operatorfoo const* const * > > GDB is looking up the symbol "operatorfoo const* const*" -- it is missing a > space between the keyword "operator" and the type name "foo const* const*". > Pedro also discovered this problem and has a patch for it pending on his > cxx-breakpoint-improvements branch. > > However, something not address by Pedro's patch is that this input of the > user-defined type needs to be canonicalized so that different "spellings" of > the type are recognized: > > (gdb) p operator const foo* const * > There is no field named operator const foo* const * > Indeed. > @@ -1630,7 +1630,13 @@ oper: OPERATOR NEW > > c_print_type ($2, NULL, &buf, -1, 0, > &type_print_raw_options); > - $$ = operator_stoken (buf.c_str ()); > + > + /* This also needs canonicalization. */ > + std::string canon > + = " " + cp_canonicalize_string (buf.c_str ()); > + if (canon.length () == 1) > + canon = " " + buf.string (); > + $$ = operator_stoken (canon.c_str ()); The length() == 1 check gave me pause. It's checking that cp_canonicalize_string returned empty of course, but it wasn't super clear on a quick skim. I think you could write it like this, making that part clearer, and also saving a few string dups and copies: /* This also needs canonicalization. */ std::string canon = cp_canonicalize_string (buf.c_str ()); if (canon.empty ()) canon = std::move (buf.string ()); $$ = operator_stoken ((" " + canon).c_str ()); > > +# Make sure conversion operator names are canonicalized and properly > +# "spelled." Period should outside the quote, I think. Otherwise OK. Thanks, Pedro Alves