[cfe-dev] Start of source range for Decl nodes.

Douglas Gregor dgregor at apple.com
Fri Mar 4 09:40:39 PST 2011


On Mar 4, 2011, at 9:38 AM, Abramo Bagnara wrote:

> Il 04/03/2011 18:16, Douglas Gregor ha scritto:
>> 
>> On Mar 4, 2011, at 9:03 AM, Abramo Bagnara wrote:
>>>> Also, the source range for a DeclaratorDecl (and anything else that stares with declaration specifiers) gets messy when there are multiple declarations, e.g.,
>>>> 
>>>> static struct Point { int x, y; } p1, *p2, get_point(int x, int y);
>>>> 
>>>> Who claims the "static" keyword? Point? p1? Everyone?
>>> 
>>> IMHO opinion there is no doubts that the full source range of p2 is from
>>> "static" to "p2" and that the full source range of "get_point" is from
>>> static to ")".
>>> 
>>> The concept underlying the source range can be easily defined as the
>>> minimal contiguous textual area that includes all the text about the
>>> declaration.
>>> 
>>> Of course if some library client wish to build a source range between
>>> name and declaration end source location is free to do that.
>>> 
>>> This solves also easily the problem to know if two declaration are
>>> inside the same group: if two consecutive declaration have same start
>>> location they are inside the same group.
>> 
>> 
>> Seems reasonable. So the starting location of Point is still 'static'?
> 
> No, the starting location of RecordDecl is on 'struct'.
> 
> Of course also the TagDecl with isEmbeddedInDeclarator flag set are in
> the same decl group (here we does not need to check the start location).

I had completely forgotten about isEmbeddedInDeclarator. Okay, it sounds like adding start locations will be enough information to make this work. Great!
	- Doug





More information about the cfe-dev mailing list