On Thu, Apr 24, 2008 at 4:31 AM, Argiris Kirtzidis <<a href="mailto:akyrtzi@gmail.com">akyrtzi@gmail.com</a>> wrote:<br><div class="gmail_quote"><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">Argiris Kirtzidis wrote:<br>
><br>
>> There's some philosophy behind my approach to function redeclarations:<br>
>> I want "normal" users of the AST to only see a single FunctionDecl for<br>
>> each function, and that FunctionDecl should contain all of the<br>
>> information that the AST contains about that function.<br>
><br>
> I agree. The only difference is in case of<br>
><br>
>  void f(int x); // #1<br>
>  void f(int x = 2); // #2<br>
><br>
><br>
> instead of merging to #2 and swaping contents with #1, thus pointer of<br>
> #1 now points to #2,<br>
> I suggest merging to #1.<br>
> In both cases, every use of 'f' will point to the same FunctionDecl node.<br>
<br>
</div>The thing is, it seems to me that 'swaping contents' complicates things<br>
(from the perspective of a ASTConsumer) without offering some benefit.<br>
Could you explain why it's useful ?</blockquote><div><br>I believe this was Doug's reason:<br><br><quote><br>That way, subsequent lookups of the function get the latest declaration.<br>This is really important, both for semantic and usability reasons:<br>

semantically, we need all of the information from later declarations<br>
in the FunctionDecl that name lookup finds, e.g.,<br>
<br>
  void f(int x); // #1<br>
  void f(int x = 2); // #2<br>
  void g() { f(); } // need to see the default argument from declaration #2<br>
<br>
The same thing happens in C, if the first declaration doesn't have a prototype.<br></quote><br><br>However, I'm curious if his approach would be able to handle this:<br><br>void f(int x = 2); // #1<br>void f(int x); // #2<br>
void g() { f(); } // need to see the default argument from declaration #1<br><br>Doug also said (emphasis added):<br><br><quote><br>So, if name lookup is going to continue to find the first declaration<br>
of a function (as it does in your suggestion and in the patch I<br>
committed), that first declaration either _*needs to accumulate<br>
information from redeclarations*_ or access to its internals needs to<br>
walk through the chain of redeclarations, e.g., to find default<br>
arguments.<br></quote><br><br>Perhaps accumulation is the approach most agreeable?<br><br>- John<br><br>P.S. Howdy everyone! I've been watching the mailing list for awhile now, but this is my first correspondence.<br>
</div></div>