Fix ObjCInterfaceDecl::lookupInstanceMethod()/lookupClassMethod() to search in inherited protocols.

Also changed ObjCInterfaceDecl::lookupClassMethod() to look through a categories protocols.

Test/patch submitted by Jean-Daniel Dupas (thanks!).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65526 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index a9f7922..1d2ad16 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -157,7 +157,7 @@
       ClassDecl->getReferencedProtocols();
     for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
          E = Protocols.end(); I != E; ++I)
-      if ((MethodDecl = (*I)->getInstanceMethod(Sel)))
+      if ((MethodDecl = (*I)->lookupInstanceMethod(Sel)))
         return MethodDecl;
     
     // Didn't find one yet - now look through categories.
@@ -171,7 +171,7 @@
         CatDecl->getReferencedProtocols();
       for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
            E = Protocols.end(); I != E; ++I)
-        if ((MethodDecl = (*I)->getInstanceMethod(Sel)))
+        if ((MethodDecl = (*I)->lookupInstanceMethod(Sel)))
           return MethodDecl;
       CatDecl = CatDecl->getNextClassCategory();
     }
@@ -193,7 +193,7 @@
     // Didn't find one yet - look through protocols.
     for (ObjCInterfaceDecl::protocol_iterator I = ClassDecl->protocol_begin(),
          E = ClassDecl->protocol_end(); I != E; ++I)
-      if ((MethodDecl = (*I)->getClassMethod(Sel)))
+      if ((MethodDecl = (*I)->lookupClassMethod(Sel)))
         return MethodDecl;
     
     // Didn't find one yet - now look through categories.
@@ -201,6 +201,14 @@
     while (CatDecl) {
       if ((MethodDecl = CatDecl->getClassMethod(Sel)))
         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)->lookupClassMethod(Sel)))
+          return MethodDecl;
       CatDecl = CatDecl->getNextClassCategory();
     }
     ClassDecl = ClassDecl->getSuperClass();