Re: [PATCH 04/22] Reimplement diagnostic_show_locus, introducing rich_location classes

2015-09-11 Thread Michael Matz
Hi,

On Thu, 10 Sep 2015, David Malcolm wrote:

> +/* FIXME: (dmalcolm)
> +   This plugin is currently the only user of
> + gcc_rich_location::add_range_with_caption
> +   As such, the symbol is present in libbackend.a, but not in "cc1",
> +   and running the plugin fails with a linker error:
> + ./diagnostic_plugin_test_show_locus.so: undefined symbol: 
> _ZN17gcc_rich_location22add_range_with_captionEjjP18diagnostic_contextPKcz
> +   which c++filt tells us is:
> + ./diagnostic_plugin_test_show_locus.so: undefined symbol: 
> gcc_rich_location::add_range_with_caption(unsigned int, unsigned int, 
> diagnostic_context*, char const*, ...)
> +
> +   I've tried various workarounds (adding DEBUG_FUNCTION to the
> +   method, taking its address), but can't seem to fix it that way.
> +   So as a nasty workaround, the following material is copied
> +   from gcc-rich-location.c: */

You need to make cc1 use _anything_ defined in the source file 
gcc-rich-location.c.  E.g. it could be some global internal variable:

int _force_me_into_cc1_hack;

which you then refer to in e.g. diagnostic-color.c (or from whereever).


Ciao,
Michael.


Re: [PATCH 04/22] Reimplement diagnostic_show_locus, introducing rich_location classes

2015-09-11 Thread Michael Matz
Hi,

On Thu, 10 Sep 2015, David Malcolm wrote:

> +/* A range of source locations.
> +
> +   Ranges are half-open:
> +   m_start is the first location within the range, whereas
> +   m_finish is the first location *after* the range.

I think you eventually decided that they are closed, not half-open, at 
least this:

> +  static source_range from_location (source_location loc)
> +  {
> +source_range result;
> +result.m_start = loc;
> +result.m_finish = loc;

and this:

> +/* Ranges are closed
> +   m_start is the first location within the range, and
> +   m_finish is the last location within the range.  */

suggest so :)


Ciao,
Michael.


Re: [PATCH 04/22] Reimplement diagnostic_show_locus, introducing rich_location classes

2015-09-11 Thread David Malcolm
On Fri, 2015-09-11 at 16:07 +0200, Michael Matz wrote:
> Hi,
> 
> On Thu, 10 Sep 2015, David Malcolm wrote:
> 
> > +/* A range of source locations.
> > +
> > +   Ranges are half-open:
> > +   m_start is the first location within the range, whereas
> > +   m_finish is the first location *after* the range.
> 
> I think you eventually decided that they are closed, not half-open, at 
> least this:

Oops.  Good catch; thanks.  Yes: in an early version of this work they
were half-open, but I found having both endpoints be within the range to
be much more convenient.


> > +  static source_range from_location (source_location loc)
> > +  {
> > +source_range result;
> > +result.m_start = loc;
> > +result.m_finish = loc;
> 
> and this:
> 
> > +/* Ranges are closed
> > +   m_start is the first location within the range, and
> > +   m_finish is the last location within the range.  */
> 
> suggest so :)