public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Ian Lance Taylor via gcc-patches" <gcc-patches@gcc.gnu.org>
To: Eduard-Mihai Burtescu <eddyb@lyken.rs>
Cc: Ian Lance Taylor <ian@airs.com>, gcc-patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] Refactor rust-demangle to be independent of C++ demangling.
Date: Fri, 08 Nov 2019 19:23:00 -0000	[thread overview]
Message-ID: <CAKOQZ8wPwDJfqbT+KzpWQkh6jBV6fDZRNRdQgtJeWGmXsCQ6Wg@mail.gmail.com> (raw)
In-Reply-To: <8636a185-77a8-425f-8512-f181940696cf@www.fastmail.com>

On Fri, Nov 8, 2019 at 11:17 AM Eduard-Mihai Burtescu <eddyb@lyken.rs> wrote:
>
> On Fri, Nov 8, 2019, at 7:43 PM, Ian Lance Taylor wrote:
> > On Fri, Nov 8, 2019 at 9:02 AM Eduard-Mihai Burtescu <eddyb@lyken.rs> wrote:
> > >
> > > Ping #2 for https://gcc.gnu.org/ml/gcc-patches/2019-10/msg01830.html
> > > Original patch (without the early exit optimization): https://gcc.gnu.org/ml/gcc-patches/2019-10/msg01591.html
> >
> > Sorry for letting this slide.
> >
> > Do we need the CHECK_OR and ERROR_AND macros?  Is there anything like
> > those elsewhere in the libiberty or GCC sources?  I would rather than
> > have ordinary code than obscure macros.
>
> Good point, I was wondering about the macros but forgot to ask explicitly, they're the least usual (for C) part of this code, they arose from porting the demangler for the new format (most of which isn't even in the current patch) from Rust, where we have facilities for conveniently propagating errors, and I wanted to avoid using goto too much for this purpose.
>
> Looking at https://gist.github.com/eddyb/c41a69378750a433767cf53fe2316768#file-rust-demangle-c I can see:
> * 5 uses of ERROR_AND
> * 20 uses of CHECK_OR
>   * 7 of those are CHECK_OR (!rdm->errored, return ); which can just be if (rdm->errored) return;
>
> So in the final code there'd be ~18 places that would need to set rdm->errored = 1; (and then return or goto cleanup).
> That's not that bad, I guess, and I'd welcome any suggestions for how to clean up that.
>
> For this current patch, however, there's only 3 uses total, so the macros are definitely overkill.
> Assuming you'd want them removed, I took the liberty of doing that and here's the fixed patch:
>
> 2019-10-22  Eduard-Mihai Burtescu  <eddyb@lyken.rs>
> include/ChangeLog:
>         * demangle.h (rust_demangle_callback): Add.
> libiberty/ChangeLog:
>         * cplus-dem.c (cplus_demangle): Use rust_demangle directly.
>         (rust_demangle): Remove.
>         * rust-demangle.c (is_prefixed_hash): Rename to is_legacy_prefixed_hash.
>         (parse_lower_hex_nibble): Rename to decode_lower_hex_nibble.
>         (parse_legacy_escape): Rename to decode_legacy_escape.
>         (rust_is_mangled): Remove.
>         (struct rust_demangler): Add.
>         (peek): Add.
>         (next): Add.
>         (struct rust_mangled_ident): Add.
>         (parse_ident): Add.
>         (rust_demangle_sym): Remove.
>         (print_str): Add.
>         (PRINT): Add.
>         (print_ident): Add.
>         (rust_demangle_callback): Add.
>         (struct str_buf): Add.
>         (str_buf_reserve): Add.
>         (str_buf_append): Add.
>         (str_buf_demangle_callback): Add.
>         (rust_demangle): Add.
>         * rust-demangle.h: Remove.

This is OK.

Thanks.

Ian

  reply	other threads:[~2019-11-08 19:23 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-22 18:24 Eduard-Mihai Burtescu
2019-10-22 18:48 ` Ian Lance Taylor via gcc-patches
2019-10-23 14:29   ` Eduard-Mihai Burtescu
2019-10-23 16:37     ` Alexander Monakov
2019-10-23 16:41       ` Segher Boessenkool
2019-10-23 17:19         ` Jakub Jelinek
2019-10-23 17:29           ` Segher Boessenkool
2019-10-23 17:37             ` Jakub Jelinek
2019-10-23 17:43               ` Segher Boessenkool
2019-10-25 12:46       ` Eduard-Mihai Burtescu
2019-10-30 16:56         ` Eduard-Mihai Burtescu
2019-11-08 17:02           ` Eduard-Mihai Burtescu
2019-11-08 17:44             ` Ian Lance Taylor via gcc-patches
2019-11-08 19:17               ` Eduard-Mihai Burtescu
2019-11-08 19:23                 ` Ian Lance Taylor via gcc-patches [this message]
2019-11-15 21:00                   ` Eduard-Mihai Burtescu
2019-11-16 15:39                 ` Jeff Law

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=CAKOQZ8wPwDJfqbT+KzpWQkh6jBV6fDZRNRdQgtJeWGmXsCQ6Wg@mail.gmail.com \
    --to=gcc-patches@gcc.gnu.org \
    --cc=eddyb@lyken.rs \
    --cc=ian@airs.com \
    --cc=iant@google.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).