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

Douglas Gregor dgregor at apple.com
Fri Mar 4 08:40:54 PST 2011


On Mar 4, 2011, at 8:36 AM, Stefan Seefeld wrote:

> On 2011-03-04 11:21, Douglas Gregor wrote:
>> On Mar 4, 2011, at 8:06 AM, Stefan Seefeld wrote:
>> 
>>> On 2011-03-04 10:30, Douglas Gregor wrote:
>>>> 
>>>>   static struct Point { int x, y; } p1, *p2, get_point(int x, int y);
>>>> 
>>>> Who claims the "static" keyword? Point? p1? Everyone?
>>>> 
>>>> 
>> Nailing down what this actually means is fairly important for the discussion of representation. What's the source range for the entire declaration of "p2" in my example? Does it include the unrelated declarator p1? Does it include get_point?
> 
> Yes, I think it's best to stay close to the C++ grammar in that respect: The above contains a single (toplevel) declaration, with 4 (toplevel) declarators. There already is a VarDecl cursor for 'p2', whose extent is just the 'p2' token itself. The declaration this is part of then is the same for all four declarators, with the same extent, from 'static' to ';'.

This is what DeclStmts essentially do via the DeclGroup mechanism. If that notion were extended to work in namespace/class/etc. contexts, we could leverage it in libclang and elsewhere.

  - Doug



More information about the cfe-dev mailing list