From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 48238 invoked by alias); 18 Oct 2017 18:29:01 -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 48002 invoked by uid 89); 18 Oct 2017 18:29:01 -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=shake, super 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 18:28:59 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AEA7DC04AC4F for ; Wed, 18 Oct 2017 18:28:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AEA7DC04AC4F Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=keiths@redhat.com Received: from valrhona.uglyboxes.com (ovpn04.gateway.prod.ext.phx2.redhat.com [10.5.9.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8BE536F11A for ; Wed, 18 Oct 2017 18:28:58 +0000 (UTC) Subject: Re: [PATCH] Canonicalize conversion operators To: gdb-patches@sourceware.org References: <1508278336-8655-1-git-send-email-keiths@redhat.com> <9b6b1fae-ea57-f5ac-da59-59c7a94b236c@redhat.com> From: Keith Seitz Message-ID: Date: Wed, 18 Oct 2017 18:29:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <9b6b1fae-ea57-f5ac-da59-59c7a94b236c@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-IsSubscribed: yes X-SW-Source: 2017-10/txt/msg00572.txt.bz2 On 10/18/2017 04:19 AM, Pedro Alves wrote: >> @@ -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 ()); > > Yes, indeed. ISTR having something similar to that at one point, but I don't know why I changed it. [Maybe that was during the C++03/C++11 shake out?] In any case, committed with that change. Thank you for the review. Keith