bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#25987: 25.2; support gcc fixit notes


From: David Malcolm
Subject: bug#25987: 25.2; support gcc fixit notes
Date: Tue, 06 Oct 2020 14:17:55 -0400
User-agent: Evolution 3.36.5 (3.36.5-1.fc32)

On Fri, 2018-03-16 at 22:19 +0200, Eli Zaretskii wrote:
> > From: David Malcolm <dmalcolm@redhat.com>
> > Date: Fri, 16 Mar 2018 12:48:07 -0400
> > 
> > It appears that Emacs can already decode from byte-offsets in a
> > line
> > back to columns
> 
> Actually, doing this translation is a pain, because it requires to
> know the original encoding used by GCC for its messages, and that
> info
> is gone by the time we have the text decoded in an Emacs buffer.
> Emacs can guess the encoding, but that guesswork is bound to
> fail.  So
> reporting the offsets in characters (a.k.a. columns) is really a
> necessity.
> 
> Thanks.

Sorry for the long delay in responding.

In GCC 11 we've revamped the column number handling in how we emit
diagnostics; see:
  https://gcc.gnu.org/pipermail/gcc-patches/2020-October/555632.html

GCC 11 diagnostics now (by default) should use actual column numbers,
rather than byte counts.

We haven't changed -fdiagnostics-parseable-fixits; it still emits its
range information in terms of byte offsets (and e.g. Eclipse already
consumes that option); this is bug-for-bug compatible with clang, I
believe (which had that option first).

Note that characters != columns, or, at least, we have to be careful
about what we mean.  Consider the case of 🙂 aka SLIGHTLY SMILING FACE
(U+1F642) which is a single unicode code point, but occupies two
columns, with its UTF-8 encoding requiring four bytes.

When I type it into an Emacs buffer, and look at the column number I
see that Emacs appears to treat the character as occupying two columns.
 Is that the kind of column numbering you would want for machine-
readable fix-it hints?

Similarly, the column numbering emitted by GCC 11 diagnostics is
affected by tab characters as tab stops, which seems to reflect Emacs
behavior as well.

I can add an additional option for fix-it hints that's similar to
-fdiagnostics-parseable-fixits, but with a different output format (or
to add an argument to that option, perhaps).

Before I do that, I wanted to check that it would be consumable by
Emacs.  What works for you?  Would it help to send the proposed GCC
patch to this bug address (or to the emacs-devel list?).

The existing option is documented here:
https://gcc.gnu.org/onlinedocs/gcc/Diagnostic-Message-Formatting-Options.html#index-fdiagnostics-parseable-fixits

Alternatively, we already have a JSON output option (-fdiagnostics-
format=json); perhaps something like that could be used?


Feature freeze for GCC 11 is about a month away; I'd love for Emacs to
be able to consume GCC fix-it hints (and have GCC and Emacs fix my
typos for me)

Dave






reply via email to

[Prev in Thread] Current Thread [Next in Thread]