diff options
author | Douglas Gregor <dgregor@apple.com> | 2011-12-27 22:43:10 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2011-12-27 22:43:10 +0000 |
commit | 375bb1413c041055262c8a416f20d10474a5eda9 (patch) | |
tree | 66e5d219fe54a005bd13828eaab0234e08ca13fc /lib/Sema | |
parent | fedb6ecbed93c6bf12a02d61b2421d6f0da3b4fc (diff) |
Eliminate ObjCClassDecl, which is redundant now that ObjCInterfaceDecl
covers both declarations (@class) and definitions (@interface) of an
Objective-C class.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147299 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema')
-rw-r--r-- | lib/Sema/CodeCompleteConsumer.cpp | 10 | ||||
-rw-r--r-- | lib/Sema/SemaCodeComplete.cpp | 19 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 15 | ||||
-rw-r--r-- | lib/Sema/SemaLookup.cpp | 6 |
4 files changed, 19 insertions, 31 deletions
diff --git a/lib/Sema/CodeCompleteConsumer.cpp b/lib/Sema/CodeCompleteConsumer.cpp index da9860361b..17e02c7473 100644 --- a/lib/Sema/CodeCompleteConsumer.cpp +++ b/lib/Sema/CodeCompleteConsumer.cpp @@ -424,8 +424,14 @@ void CodeCompletionResult::computeCursorKindAndAvailability(bool Accessible) { Availability = CXAvailability_NotAvailable; CursorKind = getCursorKindForDecl(Declaration); - if (CursorKind == CXCursor_UnexposedDecl) - CursorKind = CXCursor_NotImplemented; + if (CursorKind == CXCursor_UnexposedDecl) { + // FIXME: Forward declarations of Objective-C classes are not directly + // exposed, but we want code completion to treat them like an @interface. + if (isa<ObjCInterfaceDecl>(Declaration)) + CursorKind = CXCursor_ObjCInterfaceDecl; + else + CursorKind = CXCursor_NotImplemented; + } break; case RK_Macro: diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 79985e8b32..72cc37ccdd 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -2781,14 +2781,20 @@ CXCursorKind clang::getCursorKindForDecl(Decl *D) { return CXCursor_FunctionDecl; case Decl::ObjCCategory: return CXCursor_ObjCCategoryDecl; case Decl::ObjCCategoryImpl: return CXCursor_ObjCCategoryImplDecl; - case Decl::ObjCClass: // FIXME return CXCursor_UnexposedDecl; case Decl::ObjCForwardProtocol: // FIXME return CXCursor_UnexposedDecl; case Decl::ObjCImplementation: return CXCursor_ObjCImplementationDecl; - case Decl::ObjCInterface: return CXCursor_ObjCInterfaceDecl; + + case Decl::ObjCInterface: + if (cast<ObjCInterfaceDecl>(D)->isThisDeclarationADefinition()) + return CXCursor_ObjCInterfaceDecl; + + // Forward declarations are not directly exposed. + return CXCursor_UnexposedDecl; + case Decl::ObjCIvar: return CXCursor_ObjCIvarDecl; case Decl::ObjCMethod: return cast<ObjCMethodDecl>(D)->isInstanceMethod() @@ -5490,15 +5496,6 @@ static void AddInterfaceResults(DeclContext *Ctx, DeclContext *CurContext, if ((!OnlyForwardDeclarations || !Class->hasDefinition()) && (!OnlyUnimplemented || !Class->getImplementation())) Results.AddResult(Result(Class, 0), CurContext, 0, false); - - // Record any forward-declared interfaces we find. - if (ObjCClassDecl *Forward = dyn_cast<ObjCClassDecl>(*D)) { - ObjCInterfaceDecl *IDecl = Forward->getForwardInterfaceDecl(); - if ((!OnlyForwardDeclarations || !IDecl->hasDefinition()) && - (!OnlyUnimplemented || !IDecl->getImplementation())) - Results.AddResult(Result(IDecl, 0), CurContext, - 0, false); - } } } diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index c86f735d57..168ccfc3f5 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -1775,21 +1775,12 @@ Sema::ActOnForwardClassDeclaration(SourceLocation AtClassLoc, = dyn_cast_or_null<ObjCInterfaceDecl>(PrevDecl); ObjCInterfaceDecl *IDecl = ObjCInterfaceDecl::Create(Context, CurContext, AtClassLoc, - IdentList[i], PrevIDecl, IdentLocs[i], true); + IdentList[i], PrevIDecl, IdentLocs[i]); IDecl->setAtEndRange(IdentLocs[i]); - // Create the forward declaration. Note that we intentionally do this - // before we add the ObjCInterfaceDecl we just created, so that the - // rewriter sees the ObjCClassDecl first. - // FIXME: ObjCClassDecl should probably just go away. - ObjCClassDecl *CDecl = ObjCClassDecl::Create(Context, CurContext, AtClassLoc, - IDecl, IdentLocs[i]); - CurContext->addDecl(CDecl); - PushOnScopeChains(IDecl, TUScope); - - CheckObjCDeclScope(CDecl); - DeclsInGroup.push_back(CDecl); + CheckObjCDeclScope(IDecl); + DeclsInGroup.push_back(IDecl); } return BuildDeclaratorGroup(DeclsInGroup.data(), DeclsInGroup.size(), false); diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp index a5fc682d18..389abd5ec7 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -2776,12 +2776,6 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, Visited.add(ND); } } - } else if (ObjCClassDecl *Class = dyn_cast<ObjCClassDecl>(*D)) { - ObjCInterfaceDecl *IFace = Class->getForwardInterfaceDecl(); - if (NamedDecl *ND = Result.getAcceptableDecl(IFace)) { - Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass); - Visited.add(ND); - } } // Visit transparent contexts and inline namespaces inside this context. |