[cfe-dev] Name lookup in ObjC methods
Argiris Kirtzidis
akyrtzi at gmail.com
Tue Apr 1 19:08:49 PDT 2008
Hi,
I've attached a patch that implements the ContextDecl concept. A short
summary of the changes:
-Added ContextDecl and TranslationUnitDecl
-TranslationUnitDecl, FunctionDecl and ObjCMethodDecl inherit from
ContextDecl
-Decl class has a ContextDecl member
-All Decl subclasses receive a ContextDecl at their constructors
-Changed 'isDefinedOutsideFunctionOrMethod' to
bool ScopedDecl::isDefinedOutsideFunctionOrMethod() const {
return isa<TranslationUnitDecl>(getContextDecl());
}
-Sema sets the current ContextDecl, that subsequent new Decls should "be
under", by calling Context::PushContextDecl and Context::PopContextDecl.
Is 'Context' the appropriate place to keep track of ContextDecl, or
should I move this functionality to Sema ?
-Argiris
Chris Lattner wrote:
>>>> 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.
>
> Wow, thanks!
>
>> 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).
>
> I don't have a strong opinion. I think it does make sense to pass it
> into the ctor, but having a way to change it later could be useful.
> I'll leave it up to you. Thanks Algiris. Also, I apologize for not
> getting to your namespace patch sooner.
>
> -Chris
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: contextdecl.patch
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080401/4e654125/attachment.ksh>
More information about the cfe-dev
mailing list