public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jeff Law <law@redhat.com>
To: David Malcolm <dmalcolm@redhat.com>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH 4/4] Replace line_map union with C++ class hierarchy
Date: Thu, 14 May 2015 15:20:00 -0000	[thread overview]
Message-ID: <5554BC35.1050801@redhat.com> (raw)
In-Reply-To: <1430774878.32584.255.camel@surprise>

On 05/04/2015 03:27 PM, David Malcolm wrote:
>>> @@ -158,7 +158,7 @@ expand_location_1 (source_location loc,
>>>    	     location (toward the expansion point) that is not reserved;
>>>    	     that is, the first location that is in real source code.  */
>>>    	  loc = linemap_unwind_to_first_non_reserved_loc (line_table,
>>> -							  loc, &map);
>>> +							  loc, NULL);
>>
>> Is that really correct?
>
>
> I believe so.  The old code had (in gcc/input.c's expand_location_1):
[ ... ]
THanks for walking through it.  Mostly it just stuck out as "odd".

Given that we're depending on "not read" behaviour and latter calls 
writing into that object again (thus making the original object in 
memory "dead"), it'd be good to try and clean this up a little.

You could argue that passing in NULL like you did *is* actually that 
cleanup and I'd probably agree with the hesitation that for it to be a 
valid cleanup, linemap_resolve_location must never read what's in that 
location.

linemap_resolve_location's function header indicates it's an output, so 
I think we're OK.

So, concern eliminated :-)


>
>>     /* Return the map at a given index.  */
>>>    inline line_map *
>>>    LINEMAPS_MAP_AT (const line_maps *set, bool map_kind, int index)
>>>    {
>>> -  return &(LINEMAPS_MAPS (set, map_kind)[index]);
>>> +  if (map_kind)
>>> +    return &set->info_macro.maps[index];
>>> +  else
>>> +    return &set->info_ordinary.maps[index];
>>>    }
>> I see this pattern repeated regularly.  Any thoughts on how painful
>> it'll be to drop the map_kind argument and instead not vary the kind?
>
> I'm not sure I understand your question.
Given that kind of code, I'd be looking at the callers to determine if 
there's a reasonable way to bubble up the if (map_kind) test.

This is particularly good if bubbling it up ultimately results in 
somewhere in the call chain a statically determined map_kind.

I don't consider resolving this a requirement to go forward and it looks 
like you tried implementing this stuff with templates and ran afoul of 
gengtype.  Fair enough :-0

So I think at this point the patch is good to go.

Jeff

  reply	other threads:[~2015-05-14 15:16 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-02  0:44 [PATCH 0/4] libcpp patches David Malcolm
2015-05-02  0:44 ` [PATCH 3/4] libcpp/input.c: Add a way to visualize the linemaps David Malcolm
2015-05-04 19:20   ` Jeff Law
2015-05-13 14:05     ` David Malcolm
2015-05-02  0:44 ` [PATCH 4/4] Replace line_map union with C++ class hierarchy David Malcolm
2015-05-04 20:45   ` Jeff Law
2015-05-04 21:34     ` David Malcolm
2015-05-14 15:20       ` Jeff Law [this message]
2015-05-02  0:44 ` [PATCH 1/4] libcpp: Improvements to comments in line-map.h/c David Malcolm
2015-05-04 17:18   ` Jeff Law
2015-05-02  0:44 ` [PATCH 2/4] libcpp: Replace macro usage with C++ constructs David Malcolm
2015-05-04 19:15   ` Jeff Law
2015-05-05 18:08     ` [PATCH 2/4 v2] libcpp: Replace macro usage with C++ constructs) David Malcolm
2015-05-05 18:08       ` [PATCH 2/4 v2: part 2] libcpp: Replace macro usage with C++ constructs David Malcolm
2015-05-08 21:47         ` Jeff Law
2015-07-08 14:50         ` Thomas Schwinge
2015-07-08 15:14           ` David Malcolm
2015-05-05 18:08       ` [PATCH 2/4 v2: part 1] Move linemap_assert higher up within the file David Malcolm
2015-05-08 21:35         ` Jeff Law
2015-05-05 18:08       ` [PATCH 5/4] libcpp: Eliminate most of the non-const/reference-returning inline fns David Malcolm
2015-05-08 21:49         ` Jeff Law
2015-05-08 21:45       ` [PATCH 2/4 v2] libcpp: Replace macro usage with C++ constructs) Jeff Law
2015-05-10 15:39         ` Jan Hubicka

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=5554BC35.1050801@redhat.com \
    --to=law@redhat.com \
    --cc=dmalcolm@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /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).