Implemented when static typing is combined with protocols and use as receiver
type.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@44685 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/Decl.cpp b/AST/Decl.cpp
index cebd295..188f325 100644
--- a/AST/Decl.cpp
+++ b/AST/Decl.cpp
@@ -543,3 +543,45 @@
   }
   return NULL;
 }
+
+// lookupInstanceMethod - Lookup a instance method in the protocol and protocols
+// it inherited.
+ObjcMethodDecl *ObjcProtocolDecl::lookupInstanceMethod(Selector &Sel) {
+  ObjcMethodDecl *const*methods = getInstanceMethods();
+  int methodCount = getNumInstanceMethods();
+  for (int i = 0; i < methodCount; ++i) {
+    if (methods[i]->getSelector() == Sel) {
+      return methods[i];
+    }
+  }
+  if (getNumReferencedProtocols() > 0) {
+    ObjcProtocolDecl **RefPDecl = getReferencedProtocols();
+    
+    for (int i = 0; i < getNumReferencedProtocols(); i++) {
+      if (ObjcMethodDecl *Method = RefPDecl[i]->lookupInstanceMethod(Sel))
+        return Method;
+    }
+  }
+  return NULL;
+}
+
+// lookupInstanceMethod - Lookup a class method in the protocol and protocols
+// it inherited.
+ObjcMethodDecl *ObjcProtocolDecl::lookupClassMethod(Selector &Sel) {
+  ObjcMethodDecl *const*methods = getClassMethods();
+  int methodCount = getNumClassMethods();
+  for (int i = 0; i < methodCount; ++i) {
+    if (methods[i]->getSelector() == Sel) {
+      return methods[i];
+    }
+  }
+  if (getNumReferencedProtocols() > 0) {
+    ObjcProtocolDecl **RefPDecl = getReferencedProtocols();
+    
+    for (int i = 0; i < getNumReferencedProtocols(); i++) {
+      if (ObjcMethodDecl *Method = RefPDecl[i]->lookupClassMethod(Sel))
+        return Method;
+    }
+  }
+  return NULL;
+}