[cfe-dev] Name lookup in ObjC methods

Argiris Kirtzidis akyrtzi at gmail.com
Sun Mar 30 18:42:56 PDT 2008


Chris Lattner wrote:
>
> On Mar 30, 2008, at 6:05 PM, Argiris Kirtzidis wrote:
>
>> Chris Lattner wrote:
>>> The second is more interesting for your namespace patch.  I think we 
>>> really do need an AST-side concept of "scope", which is similar to 
>>> the parser one, but is also a bit different.  This would allow the 
>>> implementation of ScopedDecl::isDefinedOutsideFunctionOrMethod to 
>>> correctly handle typedefs defined inside functions etc.
>> Just a suggestion, how about a 'DeclContext' AST class that 
>> FunctionDecl would inherit from (and NamespaceDecl, RecordDecl):
>>
>> class FunctionDecl : public ValueDecl, public DeclContext {
>> ....
>>
>> ScopedDecl would have a DeclContext member and 
>> isDefinedOutsideFunctionOrMethod would check if it's a FunctionDecl.
>
> Yes, this is exactly what I was thinking (But ContextDecl instead of 
> DeclContext :).
>
> With this change, we could then have a TranslationUnitDecl for the 
> top-level.  It, ObjCMethod, and NamespaceDecl would also inherit from 
> DeclContext.  What do you think?
>
> -Chris
This sounds perfect. I'd like to give it a try tomorrow, if I may.
Should the ContextDecl member of ScopedDecl be a read-only property, its 
value passed to the constructors of decls ? Or should there be a 
setContextDecl method ?
(The latter would be a bit more straightforward, if read-only is not a 
requirement).



More information about the cfe-dev mailing list