aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-25 22:15:38 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2009-07-25 22:15:38 +0000
commit094e2bb6730d63e0f6919e4839522a43b7644181 (patch)
tree98c99c97959324bf44ac7aba9523ddd9d8f99838
parent467c0b165072689ef87fe8d9cd47a5b63485bcdc (diff)
Refactor ObjCProtocolDecl::lookupInstanceMethod/lookupClassMethod into one
ObjCProtocolDecl::lookupMethod. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77092 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/DeclObjC.h9
-rw-r--r--lib/AST/DeclObjC.cpp23
2 files changed, 12 insertions, 20 deletions
diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h
index 5fad478383..1e0b857f2a 100644
--- a/include/clang/AST/DeclObjC.h
+++ b/include/clang/AST/DeclObjC.h
@@ -664,8 +664,13 @@ public:
// Lookup a method. First, we search locally. If a method isn't
// found, we search referenced protocols and class categories.
- ObjCMethodDecl *lookupInstanceMethod(Selector Sel);
- ObjCMethodDecl *lookupClassMethod(Selector Sel);
+ ObjCMethodDecl *lookupMethod(Selector Sel, bool isInstance) const;
+ ObjCMethodDecl *lookupInstanceMethod(Selector Sel) const {
+ return lookupMethod(Sel, true/*isInstance*/);
+ }
+ ObjCMethodDecl *lookupClassMethod(Selector Sel) const {
+ return lookupMethod(Sel, false/*isInstance*/);
+ }
bool isForwardDecl() const { return isForwardProtoDecl; }
void setForwardDecl(bool val) { isForwardProtoDecl = val; }
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp
index d5181f75b5..7964f25b30 100644
--- a/lib/AST/DeclObjC.cpp
+++ b/lib/AST/DeclObjC.cpp
@@ -464,30 +464,17 @@ ObjCProtocolDecl *ObjCProtocolDecl::lookupProtocolNamed(IdentifierInfo *Name) {
return NULL;
}
-// lookupInstanceMethod - Lookup a instance method in the protocol and protocols
+// lookupMethod - Lookup a instance/class method in the protocol and protocols
// it inherited.
-ObjCMethodDecl *ObjCProtocolDecl::lookupInstanceMethod(Selector Sel) {
+ObjCMethodDecl *ObjCProtocolDecl::lookupMethod(Selector Sel,
+ bool isInstance) const {
ObjCMethodDecl *MethodDecl = NULL;
- if ((MethodDecl = getInstanceMethod(Sel)))
+ if ((MethodDecl = getMethod(Sel, isInstance)))
return MethodDecl;
for (protocol_iterator I = protocol_begin(), E = protocol_end(); I != E; ++I)
- if ((MethodDecl = (*I)->lookupInstanceMethod(Sel)))
- return MethodDecl;
- return NULL;
-}
-
-// lookupInstanceMethod - Lookup a class method in the protocol and protocols
-// it inherited.
-ObjCMethodDecl *ObjCProtocolDecl::lookupClassMethod(Selector Sel) {
- ObjCMethodDecl *MethodDecl = NULL;
-
- if ((MethodDecl = getClassMethod(Sel)))
- return MethodDecl;
-
- for (protocol_iterator I = protocol_begin(), E = protocol_end(); I != E; ++I)
- if ((MethodDecl = (*I)->lookupClassMethod(Sel)))
+ if ((MethodDecl = (*I)->lookupMethod(Sel, isInstance)))
return MethodDecl;
return NULL;
}