[cfe-dev] PATCH: Cleanup function redeclaration representations

Chris Lattner clattner at apple.com
Sun May 4 15:09:56 PDT 2008


On May 4, 2008, at 2:55 PM, Argiris Kirtzidis wrote:

> Chris Lattner wrote:
>> On May 4, 2008, at 2:37 PM, Argiris Kirtzidis wrote:
>> Do you mean that you can't tell if you are looking at the aggregate  
>> decl or a real decl?  If so, the aggregate decl could just have a  
>> null source location, to indicate that it is synthetic.
>
> Following your example, at first there is:
>
> void foo(int x, int y);  // #1
> 1: foo [nextredecl=null]    void foo(int x, int y);
>
> the consumer receives #1 (through HandleTopLevelDecl() )
>
> Then:
>
> void foo(int x, int y=2);  // #2
>
> A: foo [nextredecl=1]    void foo(int x, int y=2);
> 1: foo [nextredecl=2]    void foo(int x, int y);
> 2: foo [nextredecl=null]   void foo(int x, int y=2);
>
> The consumer receives #2 :
> 2: foo [nextredecl=null]   void foo(int x, int y=2);
>
> How can it find out whether #2 is a redecl and that #A is the  
> aggregate ?

Ah, you're saying that because you are given the end of the list, you  
can't just walk it.  Great point :).  Maybe the right solution is to  
build it so that the list is in the current order but that the  
aggregate version (if present) is always at the start of the list.   
Subsequent redecls would be added right after the aggregate?  In fact,  
if the list was circular, clients could then walk all of them.  In  
this case we would end up with:

void foo(int x, int y);  // #1
1: foo [nextredecl=null]    void foo(int x, int y);

the consumer receives #1 (through HandleTopLevelDecl() )


Then:

void foo(int x, int y=2);  // #2

1: foo [nextredecl=A]    void foo(int x, int y);
2: foo [nextredecl=1]    void foo(int x, int y=2);
A: foo [nextredecl=2]    void foo(int x, int y=2);

The consumer receives #2 :
2: foo [nextredecl=null]   void foo(int x, int y=2);

This way they can get #1 from #2, and they can even get A from 2...  
but that Sema can poke A efficiently.

-Chris



More information about the cfe-dev mailing list