- Teach ObjcInterfaceDecl::lookupInstance/ClassMethod to look through protocols.
- Start looking up methods in the global method pools (for "id").
- Start integrating interface types into the type system.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42971 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/AST/Decl.cpp b/AST/Decl.cpp
index 908bab4..30ca5e6 100644
--- a/AST/Decl.cpp
+++ b/AST/Decl.cpp
@@ -422,8 +422,20 @@
return methods[i];
}
}
+ // Didn't find one yet - look through protocols.
+ ObjcProtocolDecl **protocols = ClassDecl->getReferencedProtocols();
+ int numProtocols = ClassDecl->getNumIntfRefProtocols();
+ for (int pIdx = 0; pIdx < numProtocols; pIdx++) {
+ ObjcMethodDecl **methods = protocols[pIdx]->getInstanceMethods();
+ int methodCount = protocols[pIdx]->getNumInstanceMethods();
+ for (int i = 0; i < methodCount; ++i) {
+ if (methods[i]->getSelector() == Sel) {
+ return methods[i];
+ }
+ }
+ }
// Didn't find one yet - now look through categories.
- ObjcCategoryDecl *CatDecl = this->getCategoryList();
+ ObjcCategoryDecl *CatDecl = ClassDecl->getCategoryList();
while (CatDecl) {
ObjcMethodDecl **methods = CatDecl->getInstanceMethods();
int methodCount = CatDecl->getNumInstanceMethods();
@@ -451,8 +463,20 @@
return methods[i];
}
}
+ // Didn't find one yet - look through protocols.
+ ObjcProtocolDecl **protocols = ClassDecl->getReferencedProtocols();
+ int numProtocols = ClassDecl->getNumIntfRefProtocols();
+ for (int pIdx = 0; pIdx < numProtocols; pIdx++) {
+ ObjcMethodDecl **methods = protocols[pIdx]->getClassMethods();
+ int methodCount = protocols[pIdx]->getNumClassMethods();
+ for (int i = 0; i < methodCount; ++i) {
+ if (methods[i]->getSelector() == Sel) {
+ return methods[i];
+ }
+ }
+ }
// Didn't find one yet - now look through categories.
- ObjcCategoryDecl *CatDecl = this->getCategoryList();
+ ObjcCategoryDecl *CatDecl = ClassDecl->getCategoryList();
while (CatDecl) {
ObjcMethodDecl **methods = CatDecl->getClassMethods();
int methodCount = CatDecl->getNumClassMethods();