- 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();
diff --git a/AST/Type.cpp b/AST/Type.cpp
index af07d7a..762bc66 100644
--- a/AST/Type.cpp
+++ b/AST/Type.cpp
@@ -267,6 +267,10 @@
return lBuiltin->getKind() == rBuiltin->getKind();
}
+bool Type::interfaceTypesAreCompatible(QualType lhs, QualType rhs) {
+ return true; // FIXME: IMPLEMENT.
+}
+
// C99 6.2.7p1: If both are complete types, then the following additional
// requirements apply...FIXME (handle compatibility across source files).
bool Type::tagTypesAreCompatible(QualType lhs, QualType rhs) {
@@ -398,6 +402,8 @@
return tagTypesAreCompatible(lcanon, rcanon);
case Type::Builtin:
return builtinTypesAreCompatible(lcanon, rcanon);
+ case Type::ObjcInterface:
+ return interfaceTypesAreCompatible(lcanon, rcanon);
default:
assert(0 && "unexpected type");
}