public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Martin Sebor <msebor@gmail.com>
Cc: Jason Merrill <jason@redhat.com>, gcc Patches <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH RFC] c++: add color to function decl printing
Date: Mon, 13 Dec 2021 23:00:29 +0000	[thread overview]
Message-ID: <CACb0b4kxBR=Dye1YQNXO66sovqwA7us2+aB_Dmgxeathsp55yw@mail.gmail.com> (raw)
In-Reply-To: <0298dda7-3323-c44c-f164-c09a4491e069@gmail.com>

On Mon, 13 Dec 2021 at 19:22, Martin Sebor <msebor@gmail.com> wrote:

> On 12/11/21 10:39 PM, Jason Merrill via Gcc-patches wrote:
> > In reading C++ diagnostics, it's often hard to find the name of the
> function
> > in the middle of the template header, return type, parameters, and
> template
> > arguments.  So let's colorize it, and maybe the template argument
> bindings
> > while we're at it.
> >
> > I've somewhat arbitrarily chosen bold green for the function name, and
> > non-bold magenta for the template arguments.  I'm not at all attached to
> > these choices.
> >
> > A side-effect is that when this happens in a quote (i.e. %qD), the
> > rest of the quote after the function name is no longer bold.  I think
> that's
> > acceptable; returning to the bold would require maintaining a colorize
> stack
> > instead of the on/off controls we have now.
> >
> > Any thoughts?
>
> I appreciate the problem but I can't say I find this solution
> much of an improvement.  We end up with the same name in up to
> four colors: cyan, magenta, green, and black, plus bold versions
> of each, depending on where in the text the name appears.  It's
> not apparent to me what the different colors mean or how they
> help.
>

They break up the wall of text. You don't have to know what they mean to be
able to see where one chunk of text ends and another begins (in a different
colour). The colours don't *mean* anything, they're just a way to
distinguish different logical parts of the output.



> IMO, the underlying root cause for why relevant details are so
> hard to find in G++ messages is that there's so much redundancy
> and irrelevant context in the output.  For instance, for this
> test case:
>
> #include <map>
>
> std::map<const char*, const char*> m ("123", "456");
>
>
For this example, I think putting the [with T = ...; U = ...] template
arguments in a different colours helps a lot. It delineates the end of the
signature and the start of the template args, which helps navigate the wall
of text.

I don't think anybody can argue that it's easier when the [with T = ...]
part is just a continuation of the text before it. Making it a different
colour doesn't necessarily make the errors easier to understand if you're
not familiar with the code or GCC's diagnostic format, but I definitely
think it makes it easier to navigate. And that should make it easier to
figure out what the error is saying.

  reply	other threads:[~2021-12-13 23:00 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-12  5:39 Jason Merrill
2021-12-13 11:02 ` Jonathan Wakely
2021-12-13 14:58   ` [PATCH v2 " Jason Merrill
2022-01-14 21:49     ` David Malcolm
2022-01-14 22:34       ` Jonathan Wakely
2022-01-15  3:56       ` [PATCH v3 " Jason Merrill
2022-05-04 18:46         ` [PATCH v4] " Jason Merrill
2021-12-13 19:22 ` [PATCH RFC] " Martin Sebor
2021-12-13 23:00   ` Jonathan Wakely [this message]
2021-12-14  5:41   ` Jason Merrill
2021-12-14 18:02     ` Martin Sebor

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='CACb0b4kxBR=Dye1YQNXO66sovqwA7us2+aB_Dmgxeathsp55yw@mail.gmail.com' \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.com \
    --cc=msebor@gmail.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).