public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Tom Tromey <tromey@redhat.com>
To: "Manuel López-Ibáñez" <lopezibanez@gmail.com>
Cc: "Gcc Patch List" <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] caret diagnostics
Date: Thu, 14 Aug 2008 18:00:00 -0000	[thread overview]
Message-ID: <m3vdy333if.fsf@fleche.redhat.com> (raw)
In-Reply-To: <6c33472e0808140340o2a56b9f4n149025bfa8426331@mail.gmail.com>  ("Manuel =?utf-8?B?TMOzcGV6LUliw6HDsWV6Iidz?= message of "Thu\, 14 Aug 2008  12\:40\:44 +0200")

>>>>> "Manuel" == Manuel López-Ibáñez <lopezibanez@gmail.com> writes:

Manuel> The approach followed is to never free the input buffers and keep
Manuel> pointers to the start of each line tracked by each line-map.

This seems reasonable, definitely so for a first patch.

Manuel> b) Re-open the file and fseek but that is not trivial since we need to
Manuel> do it fast but still do all character conversions that we did when
Manuel> libcpp opened it the first time.

One argument in favor of this approach is that in a given compilation
we don't emit diagnostics for most source files.  So, why pay the
price of keeping those files in memory?

There are various tradeoffs we could play with.  Like, if we commonly
do not apply character set conversions, we could just mmap the files
and leave them open.  There's a lot of details here I don't remember
offhand, though (like, what kinds of weird stuff does libcpp do with
buffers?).

Manuel> Index: gcc/java/jcf-parse.c
[...]
Manuel> +      /* FIXME CARET: We should add a pointer to the input line
Manuel> +	 instead of NULL.  */

FWIW for gcj, carets don't really make sense, since we are only
compiling class files.  We rely on ecj to emit the nice errors :)

Manuel> +#ifdef USE_CARET_DIAGNOSTICS
Manuel> +      xloc.linebuf = NULL;
Manuel> +#endif

I'm with Joseph on this one -- just add the code, don't make it
conditional.  Mapped locations are not a good historical model to
follow.

Manuel> +  while (max_width > 0 && *line != '\0' && *line != '\n')
Manuel> +    {
Manuel> +      max_width--;
Manuel> +      putchar (*line);
Manuel> +      line++;
Manuel> +    }
Manuel> +  putchar('\n');
Manuel> +  gcc_assert (s.column > 0);
Manuel> +  printf (" %*c\n", s.column, '^');

I think this will run into two problems.

First, the libcpp buffer will be in UTF-8 (or UTF-EBCDIC -- nice), but
the user might be using a different charset.  So, I think we have to
iconv here.

Also, my recollection is that libcpp encodes the column by counting
characters, not by counting columns-as-would-be-displayed.  So, this
code has to have some special handling for TAB characters.

Manuel> Index: gcc/c-tree.h

This seems to be an unrelated change.

I'm not super fond of the inline function SOURCE_LINEBUFFER.  All
those caps read strangely.  And, is this really performance-sensitive
enough to need to be inline?

Unfortunately, libcpp still uses its own diagnostic output code, so
either we'd need to update that as well, or we'd have to finally make
libcpp be able to use the GCC machinery.

Tom

  parent reply	other threads:[~2008-08-14 17:34 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-14 12:12 [PATCH] caret diagnostics (was: broken FE diagnostics wrt complex expressions) Manuel López-Ibáñez
2008-08-14 12:41 ` Joseph S. Myers
2008-08-14 12:57   ` Manuel López-Ibáñez
2008-08-14 13:54     ` Joseph S. Myers
2008-08-14 14:07       ` Manuel López-Ibáñez
2008-08-14 14:41         ` Joseph S. Myers
2008-08-14 15:03           ` Manuel López-Ibáñez
2008-08-14 15:08             ` [PATCH] caret diagnostics Robert Dewar
2008-08-14 15:22               ` Joseph S. Myers
2008-08-14 15:43                 ` Robert Dewar
2008-08-14 15:48               ` Manuel López-Ibáñez
2008-08-14 16:06                 ` Robert Dewar
2008-08-14 16:18                   ` Manuel López-Ibáñez
2008-08-14 16:18                   ` Joseph S. Myers
2008-08-14 17:22                     ` Chris Lattner
2008-08-16 13:30                       ` Paolo Bonzini
2008-08-16 17:19                         ` Joseph S. Myers
2008-08-16 18:59                           ` Paolo Bonzini
2008-08-14 18:49                 ` Mark Mitchell
2008-08-14 19:10                   ` Manuel López-Ibáñez
2008-08-14 19:28                     ` Mark Mitchell
2008-08-14 15:17             ` [PATCH] caret diagnostics (was: broken FE diagnostics wrt complex expressions) Joseph S. Myers
2008-08-14 17:18               ` [PATCH] caret diagnostics Tom Tromey
2008-08-14 17:21                 ` Ralf Wildenhues
2008-08-14 17:34                   ` Joseph S. Myers
2008-08-14 18:20                   ` Tom Tromey
2008-08-14 18:34                     ` Ralf Wildenhues
2008-08-14 19:02                       ` Robert Dewar
2008-08-14 17:33                 ` Joseph S. Myers
2008-08-14 17:51                 ` Joseph S. Myers
2008-08-14 18:52                   ` Mark Mitchell
2008-08-16 10:09                 ` Gabriel Dos Reis
2008-08-16 13:00                   ` Robert Dewar
2008-08-14 15:18             ` [PATCH] caret diagnostics (was: broken FE diagnostics wrt complex expressions) Aldy Hernandez
2008-08-14 15:29               ` Manuel López-Ibáñez
2008-08-14 17:23                 ` Aldy Hernandez
2008-08-16  7:45                   ` Gabriel Dos Reis
2008-08-16 13:12                     ` [PATCH] caret diagnostics Robert Dewar
2008-08-16  7:44       ` [PATCH] caret diagnostics (was: broken FE diagnostics wrt complex expressions) Gabriel Dos Reis
2008-08-14 18:00 ` Tom Tromey [this message]
2012-04-06  8:12 [PATCH] Caret diagnostics Manuel López-Ibáñez
2012-04-06 13:42 ` Mike Stump
2012-04-06 14:12   ` Manuel López-Ibáñez
2012-04-06 22:04 ` Jason Merrill
2012-04-06 22:31   ` Manuel López-Ibáñez
2012-04-07  2:31     ` Jason Merrill
2012-04-07 22:29       ` Manuel López-Ibáñez
2012-04-08  4:09         ` Jason Merrill
2012-04-08 12:07           ` Manuel López-Ibáñez
2012-04-08 15:14             ` Gabriel Dos Reis
2012-04-08 16:10               ` Manuel López-Ibáñez
2012-04-08 16:34                 ` Gabriel Dos Reis
2012-04-08 16:14           ` Manuel López-Ibáñez
2012-04-08 16:35             ` Gabriel Dos Reis
2012-04-08 16:53               ` Manuel López-Ibáñez
2012-04-08 17:07                 ` Gabriel Dos Reis
2012-04-09  0:48             ` Jason Merrill
2012-04-09 20:02               ` Manuel López-Ibáñez
2012-04-09 22:28                 ` Jason Merrill
2012-04-10 16:46                   ` Manuel López-Ibáñez
2012-04-10 18:52                     ` Gabriel Dos Reis
2012-04-10 19:38                       ` Manuel López-Ibáñez
2012-04-11  4:04                         ` Gabriel Dos Reis
2012-04-12 16:53                           ` Tom Tromey
2012-04-12 17:08                             ` Gabriel Dos Reis
2012-04-10 22:24                       ` Mike Stump
2012-04-10 23:37                         ` Gabriel Dos Reis
2012-04-11  0:55                           ` Mike Stump
2012-04-11  3:59                             ` Gabriel Dos Reis
2012-04-10 19:32                     ` Jason Merrill
2012-04-10 19:42                       ` Manuel López-Ibáñez
2012-04-10 20:33                         ` Manuel López-Ibáñez
2012-04-11  1:57                           ` Jason Merrill
2012-04-11  4:04                           ` Gabriel Dos Reis
2012-04-11 16:40                           ` H.J. Lu
2012-04-11 18:15                             ` Manuel López-Ibáñez
2012-04-11 18:19                               ` Andrew Pinski
2012-04-11 20:12                               ` Mike Stump
2012-04-11 20:29                             ` Manuel López-Ibáñez

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=m3vdy333if.fsf@fleche.redhat.com \
    --to=tromey@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=lopezibanez@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).