[cfe-dev] PATCH: Cleanup function redeclaration representations

Argiris Kirtzidis akyrtzi at gmail.com
Thu Apr 24 08:21:58 PDT 2008


Argiris Kirtzidis wrote:
>
>>>> There's some philosophy behind my approach to function redeclarations:
>>>> I want "normal" users of the AST to only see a single FunctionDecl for
>>>> each function, and that FunctionDecl should contain all of the
>>>> information that the AST contains about that function.
>>>>
>>>>       
>>>  I agree. The only difference is in case of
>>>
>>>
>>>   void f(int x); // #1
>>>   void f(int x = 2); // #2
>>>
>>>
>>>  instead of merging to #2 and swaping contents with #1, thus pointer 
>>> of #1
>>> now points to #2,
>>>  I suggest merging to #1.
>>>  In both cases, every use of 'f' will point to the same FunctionDecl 
>>> node.
>>>     
>>
>> Ah, I understand what you mean. I think the important question is: how
>> much do you merge into #1, and do you preserve the previous
>> information in #1? Does #1 get the new parameter names from #2? New
>> typedefs in the parameter types? What about the source location?
>>
>>   void f(int x); // #1
>>   typedef int MyFlags;
>>   void f(MyFlags flags = 0); // #2
>>
>> What parts of the declaration at #2 will go into the FunctionDecl for
>> #1? Additionally: when information gets merged into #1, is that same
>> information that was in the FunctionDecl for #1 lost? (e.g., the
>> parameter name "x" it used?)
>>   
>
> These are questions that apply to either case of merging:
>
>  typedef int MyFlags;
>  void f(MyFlags flags = 0); // #1
>  void f(int x); // #2
>
>
> What parts of the declaration at #1 will go into the FunctionDecl for
> #2? Additionally: when information gets merged into #2, is that same
> information that was in the FunctionDecl for #2 lost? (e.g., the
> parameter name "x" it used?)

The point here is, given a decl #1 and a redecl #2, is there an 
advantage in merging #1 -> #2, instead of #2 -> #1 ?




More information about the cfe-dev mailing list