]> granicus.if.org Git - clang/commitdiff
tweaked my last patch to 1) preserve the protocol in
authorFariborz Jahanian <fjahanian@apple.com>
Mon, 5 Oct 2009 21:32:49 +0000 (21:32 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Mon, 5 Oct 2009 21:32:49 +0000 (21:32 +0000)
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

lib/AST/DeclObjC.cpp
lib/Sema/SemaDeclObjC.cpp

index e978a5b60fabadfc876d1bb748298eeed80828ed..7f38ac1d9ad0a6bbfd712d203c2ef25004a1bcfe 100644 (file)
@@ -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,
index 51651ab4bba4c439b05c8d6170906975f7aebcd8..8a69a861c407a65261e4007a2f2c86195a27d49a 100644 (file)
@@ -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<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.");
 }