objc: If a method is not implemented in the category implementation but
has been declared in its primary class, superclass,
or in one of their protocols, no need to issue unimplemented method. 
// rdar://10823023


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150206 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index d008385..6617dc7 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -317,7 +317,8 @@
 /// lookupMethod - This method returns an instance/class method by looking in
 /// the class, its categories, and its super classes (using a linear search).
 ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel,
-                                                bool isInstance) const {
+                                                bool isInstance,
+                                                bool noCategoryLookup) const {
   // FIXME: Should make sure no callers ever do this.
   if (!hasDefinition())
     return 0;
@@ -339,21 +340,22 @@
          E = Protocols.end(); I != E; ++I)
       if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
         return MethodDecl;
-
-    // Didn't find one yet - now look through categories.
-    ObjCCategoryDecl *CatDecl = ClassDecl->getCategoryList();
-    while (CatDecl) {
-      if ((MethodDecl = CatDecl->getMethod(Sel, isInstance)))
-        return MethodDecl;
-
-      // Didn't find one yet - look through protocols.
-      const ObjCList<ObjCProtocolDecl> &Protocols =
-        CatDecl->getReferencedProtocols();
-      for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
-           E = Protocols.end(); I != E; ++I)
-        if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
+    if (!noCategoryLookup) {
+      // Didn't find one yet - now look through categories.
+      ObjCCategoryDecl *CatDecl = ClassDecl->getCategoryList();
+      while (CatDecl) {
+        if ((MethodDecl = CatDecl->getMethod(Sel, isInstance)))
           return MethodDecl;
-      CatDecl = CatDecl->getNextClassCategory();
+
+        // Didn't find one yet - look through protocols.
+        const ObjCList<ObjCProtocolDecl> &Protocols =
+          CatDecl->getReferencedProtocols();
+        for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
+             E = Protocols.end(); I != E; ++I)
+          if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
+            return MethodDecl;
+        CatDecl = CatDecl->getNextClassCategory();
+      }
     }
     ClassDecl = ClassDecl->getSuperClass();
   }