[cfe-dev] Name lookup in ObjC methods
Chris Lattner
clattner at apple.com
Tue Apr 1 20:46:00 PDT 2008
On Apr 1, 2008, at 7:08 PM, Argiris Kirtzidis wrote:
> Hi,
>
> I've attached a patch that implements the ContextDecl concept.
Nice!
> A short summary of the changes:
>
> -Added ContextDecl and TranslationUnitDecl
Ok.
> -TranslationUnitDecl, FunctionDecl and ObjCMethodDecl inherit from
> ContextDecl
Yep.
> -Decl class has a ContextDecl member
Should this be in Decl, or in ScopedDecl? It doesn't make much sense
for struct fields (for example) to have this context pointer.
> -All Decl subclasses receive a ContextDecl at their constructors
Sounds good, but only scopedecl if possible.
> -Changed 'isDefinedOutsideFunctionOrMethod' to
>
> bool ScopedDecl::isDefinedOutsideFunctionOrMethod() const {
> return isa<TranslationUnitDecl>(getContextDecl());
> }
Woo, very nice!
> -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 ?
I think this makes more sense to be in Sema than in ASTContext. The
notion of the "current" context is something that changes after
parsing (which makes sense for Sema to have) but ASTContext represents
the code "after" parsing.
Some minor stuff:
Please move "CurContext" into Sema and the ContextDecl member to
ScopeDecl if possible.
instead of Decl::getContextDecl(), how about just
[Scope]Decl::getContext() ?
+/// ContextDecl - This is used only as base class of specific decl
types that
+/// can act as declaration contexts. This decls are:
This looks great, and your implementation is very clever. Would it be
possible to move ContextDecl to a ContextDecl.h file that Decl.h
#includes?
Can the body of ScopedDecl::isDefinedOutsideFunctionOrMethod be moved
inline?
This is great work Argiris - I'm very impressed,
-Chris
More information about the cfe-dev
mailing list