From: Pedro Alves <palves@redhat.com>
To: Keith Seitz <keiths@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] Canonicalize conversion operators
Date: Wed, 18 Oct 2017 11:20:00 -0000 [thread overview]
Message-ID: <9b6b1fae-ea57-f5ac-da59-59c7a94b236c@redhat.com> (raw)
In-Reply-To: <1508278336-8655-1-git-send-email-keiths@redhat.com>
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
next prev parent reply other threads:[~2017-10-18 11:20 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-17 22:12 Keith Seitz
2017-10-18 11:20 ` Pedro Alves [this message]
2017-10-18 18:29 ` Keith Seitz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9b6b1fae-ea57-f5ac-da59-59c7a94b236c@redhat.com \
--to=palves@redhat.com \
--cc=gdb-patches@sourceware.org \
--cc=keiths@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).