This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Canonicalize conversion operators
- From: Keith Seitz <keiths at redhat dot com>
- To: gdb-patches at sourceware dot org
- Date: Wed, 18 Oct 2017 11:28:58 -0700
- Subject: Re: [PATCH] Canonicalize conversion operators
- Authentication-results: sourceware.org; auth=none
- 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 at redhat dot com
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com AEA7DC04AC4F
- References: <1508278336-8655-1-git-send-email-keiths@redhat.com> <9b6b1fae-ea57-f5ac-da59-59c7a94b236c@redhat.com>
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