[cfe-dev] [PATCH] Function redeclaration and PR2360

Ted Kremenek kremenek at apple.com
Tue May 27 09:52:30 PDT 2008


On May 27, 2008, at 9:44 AM, Eli Friedman wrote:

> On Tue, May 27, 2008 at 9:17 AM, Argiris Kirtzidis  
> <akyrtzi at gmail.com> wrote:
>> Do you guys disagree with the suggestion here ? :
>> http://lists.cs.uiuc.edu/pipermail/cfe-dev/2008-May/001644.html
>> I was going to implement that one. The result will be that  
>> DeclRefExprs that
>> refer to the same function will always refer to the same  
>> FunctionDecl as
>> well.
>
> Mmm... the issue with that exact approach is that we lose information:
> once the AST is completely constructed, you can't tell which
> declaration a DeclRef refers to.

This makes sense.

>  Usually, it doesn't really matter;
> however, a rewriting tool might be interested in knowing which
> declaration is referred to, and we'd have funny cases where the type
> of the DeclRef and the type of the Decl itself are different.

Interesting.  Can you give an example of this in the case of  
FunctionDecls?

>  Still
> might be workable, though.

It can be difficult to accurately reconstruct information after an  
"abstraction leak", but a global map (as you suggested) would provide  
the same functionality as Argiris's proposed change.  And, as I  
already mentioned, we will need some global name resolution anyway,  
especially when dealing with multiple translation units.  Handling  
multiple Decls within the same translation unit that refer to the same  
entity might just be a special case within that more general problem.





More information about the cfe-dev mailing list