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/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 51651ab..8a69a86 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -588,15 +588,13 @@
     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 @@
       }
     }
   } else if (ObjCCategoryDecl *C = dyn_cast<ObjCCategoryDecl>(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.");
 }