[cfe-commits] [PATCH] ObjC: interface decls pointing to implementation decls
steve naroff
snaroff at apple.com
Mon Jul 20 05:50:12 PDT 2009
Hey Argyrios,
I really like the idea of moving this association from Sema->ASTContext.
From my perspective, adding getImplementation to the
ObjCContainerDecl AST has the following drawbacks:
- The ObjCImplDecl is rarely used. For example Cocoa.h contains ~700
"containers" that don't have implementations (which include classes,
categories, and protocols). Even for non-system classes/categories/
protocols, the slot would be rarely used as well (since most ObjC
files/modules contain a very small number of implementations...1 is
very common).
- The ObjCImplDecl doesn't make sense for protocols (since they don't
have an implementation).
Did you consider adding the following API to ASTContext?
For example...
ObjCImplementationDecl
*ASTContext::getImplementation(ObjCInterfaceDecl *);
ObjCCategoryImplDecl *ASTContext::getImplementation(ObjCCategoryDecl *);
ASTContext would use a "Map" to associate the ObjCContainerDecl with
it's ObjCImplDecl.
snaroff
On Jul 19, 2009, at 9:19 PM, Argyrios Kyrtzidis wrote:
> Hi all,
>
> Currently you can't find the implementation of an interface using only
> the ASTContext. This results in Sema doing name lookups when looking
> for methods or keeping data structures like ObjCCategoryImpls.
> IMO the ASTContext should provide the information that "this
> ObjCIntefaceDecl is implemented by this ObjCImplementationDecl". This
> way Sema gets simplified, it can get at the implementation without
> doing name lookups
> and a client can easily access such information without the need to
> build data structures like Sema's.
>
> I attached 3 patches for your reviewal pleasure:
>
> objc_impl1.patch: Modifies ObjCContainerDecl so that it can point to
> its implementation. As a bonus, Sema is modified to emit an error when
> a category is reimplemented (previously it didn't emit any
> diagnostic).
> objc_impl2.patch: Sema::LookupObjCImplementation() is removed, and
> ObjCInterfaceDecl::getImplementation() is used in its place. No name
> lookups, w00t!
> objc_impl3.patch: The ObjCCategoryImpls vector is removed from Sema,
> and ObjCInterfaceDecl::getCategoryClassMethod() and
> ObjCInterfaceDecl::getCategoryInstanceMethod() are used for the same
> functionality.
>
> Let me know what you think.
>
> -Argiris
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list