From: Fariborz Jahanian Date: Mon, 5 Oct 2009 21:32:49 +0000 (+0000) Subject: tweaked my last patch to 1) preserve the protocol in X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b106fc635b1523952332131785b700453a936e49;p=clang tweaked my last patch to 1) preserve the protocol in extension class's protocol list so its AST is complete. 2) Because of this no need to issue warning on unimplemeted methods coming from the extended class protocols because warning is issued when class definition is seen. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@83326 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index e978a5b60f..7f38ac1d9a 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -148,15 +148,13 @@ void ObjCInterfaceDecl::mergeClassExtensionProtocolList( } if (ProtocolRefs.empty()) return; - + // Merge ProtocolRefs into class's protocol list; for (protocol_iterator p = protocol_begin(), e = protocol_end(); p != e; p++) ProtocolRefs.push_back(*p); ReferencedProtocols.Destroy(C); unsigned NumProtoRefs = ProtocolRefs.size(); setProtocolList((ObjCProtocolDecl**)&ProtocolRefs[0], NumProtoRefs, C); - // Merge ProtocolRefs into class's protocol list; - } ObjCIvarDecl *ObjCInterfaceDecl::lookupInstanceVariable(IdentifierInfo *ID, diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index 51651ab4bb..8a69a861c4 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -588,15 +588,13 @@ ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, CDecl->insertNextClassCategory(); if (NumProtoRefs) { + CDecl->setProtocolList((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs, + Context); + CDecl->setLocEnd(EndProtoLoc); // Protocols in the class extension belong to the class. if (!CDecl->getIdentifier()) IDecl->mergeClassExtensionProtocolList((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs,Context); - else { - CDecl->setProtocolList((ObjCProtocolDecl**)ProtoRefs, NumProtoRefs, - Context); - CDecl->setLocEnd(EndProtoLoc); - } } CheckObjCDeclScope(CDecl); @@ -1102,10 +1100,14 @@ void Sema::ImplMethodsVsClassMethods(ObjCImplDecl* IMPDecl, } } } else if (ObjCCategoryDecl *C = dyn_cast(CDecl)) { - for (ObjCCategoryDecl::protocol_iterator PI = C->protocol_begin(), - E = C->protocol_end(); PI != E; ++PI) - CheckProtocolMethodDefs(IMPDecl->getLocation(), *PI, IncompleteImpl, - InsMap, ClsMap, C->getClassInterface()); + // For extended class, unimplemented methods in its protocols will + // be reported in the primary class. + if (C->getIdentifier()) { + for (ObjCCategoryDecl::protocol_iterator PI = C->protocol_begin(), + E = C->protocol_end(); PI != E; ++PI) + CheckProtocolMethodDefs(IMPDecl->getLocation(), *PI, IncompleteImpl, + InsMap, ClsMap, C->getClassInterface()); + } } else assert(false && "invalid ObjCContainerDecl type."); }