diff options
author | Steve Naroff <snaroff@apple.com> | 2009-01-08 17:28:14 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2009-01-08 17:28:14 +0000 |
commit | 0701bbb228dfd87e1fe82a0a4b7b9facfecb43da (patch) | |
tree | 0e6483e9a1755c00b458662c0cd52c26d132b70e /lib/AST/DeclBase.cpp | |
parent | 7e5d6ed47dcedce35043de59ee00464b681bc786 (diff) |
This is a large/messy diff that unifies the ObjC AST's with DeclContext.
- ObjCContainerDecl's (ObjCInterfaceDecl/ObjCCategoryDecl/ObjCProtocolDecl), ObjCCategoryImpl, & ObjCImplementation are all DeclContexts.
- ObjCMethodDecl is now a ScopedDecl (so it can play nicely with DeclContext).
- ObjCContainerDecl now does iteration/lookup using DeclContext infrastructure (no more linear search:-)
- Removed ASTContext argument to DeclContext::lookup(). It wasn't being used and complicated it's use from an ObjC AST perspective.
- Added Sema::ProcessPropertyDecl() and removed Sema::diagnosePropertySetterGetterMismatch().
- Simplified Sema::ActOnAtEnd() considerably. Still more work to do.
- Fixed an incorrect casting assumption in Sema::getCurFunctionOrMethodDecl(), now that ObjCMethodDecl is a ScopedDecl.
- Removed addPropertyMethods from ObjCInterfaceDecl/ObjCCategoryDecl/ObjCProtocolDecl.
This passes all the tests on my machine. Since many of the changes are central to the way ObjC finds it's methods, I expect some fallout (and there are still a handful of FIXME's). Nevertheless, this should be a step in the right direction.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61929 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r-- | lib/AST/DeclBase.cpp | 30 |
1 files changed, 20 insertions, 10 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index f14dc3c717..49890144a9 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -419,7 +419,7 @@ bool DeclContext::isTransparentContext() const { return false; } -DeclContext *DeclContext::getPrimaryContext(ASTContext &Context) { +DeclContext *DeclContext::getPrimaryContext() { switch (DeclKind) { case Decl::TranslationUnit: case Decl::LinkageSpec: @@ -468,9 +468,15 @@ DeclContext *DeclContext::getPrimaryContext(ASTContext &Context) { return this; case Decl::ObjCInterface: + case Decl::ObjCProtocol: + case Decl::ObjCCategory: // FIXME: Can Objective-C interfaces be forward-declared? return this; + case Decl::ObjCImplementation: + case Decl::ObjCCategoryImpl: + return this; + default: assert(DeclKind >= Decl::FunctionFirst && DeclKind <= Decl::FunctionLast && "Unknown DeclContext kind"); @@ -486,6 +492,10 @@ DeclContext *DeclContext::getNextContext() { case Decl::CXXRecord: case Decl::ObjCMethod: case Decl::ObjCInterface: + case Decl::ObjCCategory: + case Decl::ObjCProtocol: + case Decl::ObjCImplementation: + case Decl::ObjCCategoryImpl: case Decl::LinkageSpec: case Decl::Block: // There is only one DeclContext for these entities. @@ -511,7 +521,7 @@ void DeclContext::addDecl(ASTContext &Context, ScopedDecl *D, bool AllowLookup) /// buildLookup - Build the lookup data structure with all of the /// declarations in DCtx (and any other contexts linked to it or /// transparent contexts nested within it). -void DeclContext::buildLookup(ASTContext &Context, DeclContext *DCtx) { +void DeclContext::buildLookup(DeclContext *DCtx) { for (; DCtx; DCtx = DCtx->getNextContext()) { for (decl_iterator D = DCtx->decls_begin(), DEnd = DCtx->decls_end(); D != DEnd; ++D) { @@ -522,22 +532,22 @@ void DeclContext::buildLookup(ASTContext &Context, DeclContext *DCtx) { // add its members (recursively). if (DeclContext *InnerCtx = dyn_cast<DeclContext>(*D)) if (InnerCtx->isTransparentContext()) - buildLookup(Context, InnerCtx->getPrimaryContext(Context)); + buildLookup(InnerCtx->getPrimaryContext()); } } } DeclContext::lookup_result -DeclContext::lookup(ASTContext &Context, DeclarationName Name) { - DeclContext *PrimaryContext = getPrimaryContext(Context); +DeclContext::lookup(DeclarationName Name) { + DeclContext *PrimaryContext = getPrimaryContext(); if (PrimaryContext != this) - return PrimaryContext->lookup(Context, Name); + return PrimaryContext->lookup(Name); /// If there is no lookup data structure, build one now by walking /// all of the linked DeclContexts (in declaration order!) and /// inserting their values. if (LookupPtr.getPointer() == 0) - buildLookup(Context, this); + buildLookup(this); if (isLookupMap()) { StoredDeclsMap *Map = static_cast<StoredDeclsMap*>(LookupPtr.getPointer()); @@ -563,8 +573,8 @@ DeclContext::lookup(ASTContext &Context, DeclarationName Name) { } DeclContext::lookup_const_result -DeclContext::lookup(ASTContext &Context, DeclarationName Name) const { - return const_cast<DeclContext*>(this)->lookup(Context, Name); +DeclContext::lookup(DeclarationName Name) const { + return const_cast<DeclContext*>(this)->lookup(Name); } const DeclContext *DeclContext::getLookupContext() const { @@ -575,7 +585,7 @@ const DeclContext *DeclContext::getLookupContext() const { } void DeclContext::insert(ASTContext &Context, ScopedDecl *D) { - DeclContext *PrimaryContext = getPrimaryContext(Context); + DeclContext *PrimaryContext = getPrimaryContext(); if (PrimaryContext != this) { PrimaryContext->insert(Context, D); return; |