diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-08-27 20:50:59 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-08-27 20:50:59 +0000 |
commit | 95ed7784a335aca53b0c6e952cf31a4cfb633360 (patch) | |
tree | dccf10738853796c0c6669e8f882a2788f57f56c /lib/Sema | |
parent | 74cfb23d44de82f1932f0229b742805b0b3c3719 (diff) |
objective-c: Treat top-level objective-c declarations
, such as list of forward @class decls, in a DeclGroup
node. Deal with its consequence throught clang. This
is in preparation for more Sema work ahead. // rdar://8843851.
Feel free to reverse if it breaks something important
and I am unavailable.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@138709 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 11 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 22 | ||||
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 5 |
3 files changed, 15 insertions, 23 deletions
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index ef54fbcad8..5e19148c38 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -5405,12 +5405,11 @@ static void AddInterfaceResults(DeclContext *Ctx, DeclContext *CurContext, // Record any forward-declared interfaces we find. if (ObjCClassDecl *Forward = dyn_cast<ObjCClassDecl>(*D)) { - for (ObjCClassDecl::iterator C = Forward->begin(), CEnd = Forward->end(); - C != CEnd; ++C) - if ((!OnlyForwardDeclarations || C->getInterface()->isForwardDecl()) && - (!OnlyUnimplemented || !C->getInterface()->getImplementation())) - Results.AddResult(Result(C->getInterface(), 0), CurContext, - 0, false); + ObjCInterfaceDecl *IDecl = Forward->getForwardInterfaceDecl(); + if ((!OnlyForwardDeclarations || IDecl->isForwardDecl()) && + (!OnlyUnimplemented || !IDecl->getImplementation())) + Results.AddResult(Result(IDecl, 0), CurContext, + 0, false); } } } diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index af14aa4f84..c7d3590fb8 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -1657,13 +1657,12 @@ void Sema::ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl* IMPDecl, } /// ActOnForwardClassDeclaration - -Decl * +Sema::DeclGroupPtrTy Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc, IdentifierInfo **IdentList, SourceLocation *IdentLocs, unsigned NumElts) { - SmallVector<ObjCInterfaceDecl*, 32> Interfaces; - + SmallVector<Decl *, 8> DeclsInGroup; for (unsigned i = 0; i != NumElts; ++i) { // Check for another declaration kind with the same name. NamedDecl *PrevDecl @@ -1708,17 +1707,14 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc, PushOnScopeChains(IDecl, TUScope, false); CurContext->makeDeclVisibleInContext(IDecl, true); } - - Interfaces.push_back(IDecl); + ObjCClassDecl *CDecl = ObjCClassDecl::Create(Context, CurContext, AtClassLoc, + IDecl, IdentLocs[i]); + CurContext->addDecl(CDecl); + CheckObjCDeclScope(CDecl); + DeclsInGroup.push_back(CDecl); } - - assert(Interfaces.size() == NumElts); - ObjCClassDecl *CDecl = ObjCClassDecl::Create(Context, CurContext, AtClassLoc, - Interfaces.data(), IdentLocs, - Interfaces.size()); - CurContext->addDecl(CDecl); - CheckObjCDeclScope(CDecl); - return CDecl; + + return BuildDeclaratorGroup(DeclsInGroup.data(), DeclsInGroup.size(), false); } static bool tryMatchRecordTypes(ASTContext &Context, diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index 240eb5f1bf..7df049815a 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -2670,14 +2670,11 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, } } } else if (ObjCClassDecl *Class = dyn_cast<ObjCClassDecl>(*D)) { - for (ObjCClassDecl::iterator I = Class->begin(), IEnd = Class->end(); - I != IEnd; ++I) { - ObjCInterfaceDecl *IFace = I->getInterface(); + ObjCInterfaceDecl *IFace = Class->getForwardInterfaceDecl(); if (Result.isAcceptableDecl(IFace)) { Consumer.FoundDecl(IFace, Visited.checkHidden(IFace), InBaseClass); Visited.add(IFace); } - } } // Visit transparent contexts and inline namespaces inside this context. |