aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclObjC.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-25 22:15:51 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-25 22:15:51 +0000
commitaa5420c1e36ab8e0e4bb87239d8b73a3a8ce75db (patch)
treed64cac829d083d8d03b3f94d120382c5b77879c5 /lib/AST/DeclObjC.cpp
parent094e2bb6730d63e0f6919e4839522a43b7644181 (diff)
Refactor ObjCInterfaceDecl::lookupInstanceMethod/lookupClassMethod into one
ObjCInterfaceDecl::lookupMethod. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77093 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclObjC.cpp')
-rw-r--r--lib/AST/DeclObjC.cpp51
1 files changed, 8 insertions, 43 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index 7964f25b30..7b3c853215 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -145,14 +145,15 @@ ObjCInterfaceDecl *ObjCInterfaceDecl::lookupInheritedClass(
return NULL;
}
-/// lookupInstanceMethod - This method returns an instance method by looking in
+/// 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::lookupInstanceMethod(Selector Sel) {
- ObjCInterfaceDecl* ClassDecl = this;
+ObjCMethodDecl *ObjCInterfaceDecl::lookupMethod(Selector Sel,
+ bool isInstance) const {
+ const ObjCInterfaceDecl* ClassDecl = this;
ObjCMethodDecl *MethodDecl = 0;
while (ClassDecl != NULL) {
- if ((MethodDecl = ClassDecl->getInstanceMethod(Sel)))
+ if ((MethodDecl = ClassDecl->getMethod(Sel, isInstance)))
return MethodDecl;
// Didn't find one yet - look through protocols.
@@ -160,49 +161,13 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupInstanceMethod(Selector Sel) {
ClassDecl->getReferencedProtocols();
for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
E = Protocols.end(); I != E; ++I)
- if ((MethodDecl = (*I)->lookupInstanceMethod(Sel)))
- return MethodDecl;
-
- // Didn't find one yet - now look through categories.
- ObjCCategoryDecl *CatDecl = ClassDecl->getCategoryList();
- while (CatDecl) {
- if ((MethodDecl = CatDecl->getInstanceMethod(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)->lookupInstanceMethod(Sel)))
- return MethodDecl;
- CatDecl = CatDecl->getNextClassCategory();
- }
- ClassDecl = ClassDecl->getSuperClass();
- }
- return NULL;
-}
-
-// lookupClassMethod - This method returns a class method by looking in the
-// class, its categories, and its super classes (using a linear search).
-ObjCMethodDecl *ObjCInterfaceDecl::lookupClassMethod(Selector Sel) {
- ObjCInterfaceDecl* ClassDecl = this;
- ObjCMethodDecl *MethodDecl = 0;
-
- while (ClassDecl != NULL) {
- if ((MethodDecl = ClassDecl->getClassMethod(Sel)))
- return MethodDecl;
-
- // 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)->lookupClassMethod(Sel)))
+ 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->getClassMethod(Sel)))
+ if ((MethodDecl = CatDecl->getMethod(Sel, isInstance)))
return MethodDecl;
// Didn't find one yet - look through protocols.
@@ -210,7 +175,7 @@ ObjCMethodDecl *ObjCInterfaceDecl::lookupClassMethod(Selector Sel) {
CatDecl->getReferencedProtocols();
for (ObjCList<ObjCProtocolDecl>::iterator I = Protocols.begin(),
E = Protocols.end(); I != E; ++I)
- if ((MethodDecl = (*I)->lookupClassMethod(Sel)))
+ if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
return MethodDecl;
CatDecl = CatDecl->getNextClassCategory();
}