diff options
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/CodeCompleteConsumer.cpp | 7 | ||||
-rw-r--r-- | clang/lib/Sema/SemaCodeComplete.cpp | 21 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclObjC.cpp | 18 | ||||
-rw-r--r-- | clang/lib/Sema/SemaLookup.cpp | 12 |
4 files changed, 16 insertions, 42 deletions
diff --git a/clang/lib/Sema/CodeCompleteConsumer.cpp b/clang/lib/Sema/CodeCompleteConsumer.cpp index 17e02c7473d..80496c5c441 100644 --- a/clang/lib/Sema/CodeCompleteConsumer.cpp +++ b/clang/lib/Sema/CodeCompleteConsumer.cpp @@ -425,10 +425,13 @@ void CodeCompletionResult::computeCursorKindAndAvailability(bool Accessible) { CursorKind = getCursorKindForDecl(Declaration); 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. + // FIXME: Forward declarations of Objective-C classes and protocols + // are not directly exposed, but we want code completion to treat them + // like a definition. if (isa<ObjCInterfaceDecl>(Declaration)) CursorKind = CXCursor_ObjCInterfaceDecl; + else if (isa<ObjCProtocolDecl>(Declaration)) + CursorKind = CXCursor_ObjCProtocolDecl; else CursorKind = CXCursor_NotImplemented; } diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp index 6843ca7e6cb..78e3c355d62 100644 --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -2783,9 +2783,6 @@ CXCursorKind clang::getCursorKindForDecl(Decl *D) { case Decl::ObjCCategoryImpl: return CXCursor_ObjCCategoryImplDecl; // FIXME return CXCursor_UnexposedDecl; - case Decl::ObjCForwardProtocol: - // FIXME - return CXCursor_UnexposedDecl; case Decl::ObjCImplementation: return CXCursor_ObjCImplementationDecl; case Decl::ObjCInterface: @@ -2804,7 +2801,12 @@ CXCursorKind clang::getCursorKindForDecl(Decl *D) { case Decl::CXXDestructor: return CXCursor_Destructor; case Decl::CXXConversion: return CXCursor_ConversionFunction; case Decl::ObjCProperty: return CXCursor_ObjCPropertyDecl; - case Decl::ObjCProtocol: return CXCursor_ObjCProtocolDecl; + case Decl::ObjCProtocol: + if (cast<ObjCProtocolDecl>(D)->isThisDeclarationADefinition()) + return CXCursor_ObjCProtocolDecl; + + return CXCursor_UnexposedDecl; + case Decl::ParmVar: return CXCursor_ParmDecl; case Decl::Typedef: return CXCursor_TypedefDecl; case Decl::TypeAlias: return CXCursor_TypeAliasDecl; @@ -5422,17 +5424,6 @@ static void AddProtocolResults(DeclContext *Ctx, DeclContext *CurContext, if (ObjCProtocolDecl *Proto = dyn_cast<ObjCProtocolDecl>(*D)) if (!OnlyForwardDeclarations || !Proto->hasDefinition()) Results.AddResult(Result(Proto, 0), CurContext, 0, false); - - // Record any forward-declared protocols we find. - if (ObjCForwardProtocolDecl *Forward - = dyn_cast<ObjCForwardProtocolDecl>(*D)) { - for (ObjCForwardProtocolDecl::protocol_iterator - P = Forward->protocol_begin(), - PEnd = Forward->protocol_end(); - P != PEnd; ++P) - if (!OnlyForwardDeclarations || !(*P)->hasDefinition()) - Results.AddResult(Result(*P, 0), CurContext, 0, false); - } } } diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp index 3612e94371b..51d282a546c 100644 --- a/clang/lib/Sema/SemaDeclObjC.cpp +++ b/clang/lib/Sema/SemaDeclObjC.cpp @@ -694,14 +694,12 @@ void Sema::DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, } /// ActOnForwardProtocolDeclaration - Handle @protocol foo; -Decl * +Sema::DeclGroupPtrTy Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc, const IdentifierLocPair *IdentList, unsigned NumElts, AttributeList *attrList) { - SmallVector<ObjCProtocolDecl*, 32> Protocols; - SmallVector<SourceLocation, 8> ProtoLocs; - + SmallVector<Decl *, 8> DeclsInGroup; for (unsigned i = 0; i != NumElts; ++i) { IdentifierInfo *Ident = IdentList[i].first; ObjCProtocolDecl *PrevDecl = LookupProtocol(Ident, IdentList[i].second, @@ -712,6 +710,7 @@ Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc, PrevDecl, /*isForwardDecl=*/true); PushOnScopeChains(PDecl, TUScope); + CheckObjCDeclScope(PDecl); if (attrList) ProcessDeclAttributeList(TUScope, PDecl, attrList); @@ -719,17 +718,10 @@ Sema::ActOnForwardProtocolDeclaration(SourceLocation AtProtocolLoc, if (PrevDecl) mergeDeclAttributes(PDecl, PrevDecl); - Protocols.push_back(PDecl); - ProtoLocs.push_back(IdentList[i].second); + DeclsInGroup.push_back(PDecl); } - ObjCForwardProtocolDecl *PDecl = - ObjCForwardProtocolDecl::Create(Context, CurContext, AtProtocolLoc, - Protocols.data(), Protocols.size(), - ProtoLocs.data()); - CurContext->addDecl(PDecl); - CheckObjCDeclScope(PDecl); - return PDecl; + return BuildDeclaratorGroup(DeclsInGroup.data(), DeclsInGroup.size(), false); } Decl *Sema:: diff --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp index 63d14f46c1e..4f53487dcdb 100644 --- a/clang/lib/Sema/SemaLookup.cpp +++ b/clang/lib/Sema/SemaLookup.cpp @@ -2767,18 +2767,6 @@ static void LookupVisibleDecls(DeclContext *Ctx, LookupResult &Result, Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass); Visited.add(ND); } - } else if (ObjCForwardProtocolDecl *ForwardProto - = dyn_cast<ObjCForwardProtocolDecl>(*D)) { - for (ObjCForwardProtocolDecl::protocol_iterator - P = ForwardProto->protocol_begin(), - PEnd = ForwardProto->protocol_end(); - P != PEnd; - ++P) { - if (NamedDecl *ND = Result.getAcceptableDecl(*P)) { - Consumer.FoundDecl(ND, Visited.checkHidden(ND), Ctx, InBaseClass); - Visited.add(ND); - } - } } // Visit transparent contexts and inline namespaces inside this context. |