]> granicus.if.org Git - clang/commitdiff
Refactor ObjCImplDecl::getInstanceMethod/getClassMethod into one
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 25 Jul 2009 22:16:03 +0000 (22:16 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Sat, 25 Jul 2009 22:16:03 +0000 (22:16 +0000)
ObjCImplDecl::getMethod.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77094 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp

index 630723a60a159a71e412cc826cf6652b0fa6e8f6..96ac693eb4aa1f49db7251d1fe4584047d2079d8 100644 (file)
@@ -872,11 +872,12 @@ public:
   }
   
   // Get the local instance/class method declared in this interface.
-  ObjCMethodDecl *getInstanceMethod(Selector Sel) const;
-  ObjCMethodDecl *getClassMethod(Selector Sel) const;
-  ObjCMethodDecl *getMethod(Selector Sel, bool isInstance) const {
-    return isInstance ? getInstanceMethod(Sel) 
-                      : getClassMethod(Sel);
+  ObjCMethodDecl *getMethod(Selector Sel, bool isInstance) const;
+  ObjCMethodDecl *getInstanceMethod(Selector Sel) const {
+    return getMethod(Sel, true/*isInstance*/);
+  }
+  ObjCMethodDecl *getClassMethod(Selector Sel) const {
+    return getMethod(Sel, false/*isInstance*/);
   }
   
   void addPropertyImplementation(ObjCPropertyImplDecl *property);
index 7b3c853215f21bfb7b31200529d3010799765203..d9005f8f3c3107057b351e38d722aebea979558c 100644 (file)
@@ -587,10 +587,10 @@ FindPropertyImplDecl(IdentifierInfo *Id) const {
   return 0;
 }
 
-// getInstanceMethod - This method returns an instance method by looking in
+// getMethod - This method returns an instance/class method by looking in
 // the class implementation. Unlike interfaces, we don't look outside the
 // implementation.
-ObjCMethodDecl *ObjCImplDecl::getInstanceMethod(Selector Sel) const {
+ObjCMethodDecl *ObjCImplDecl::getMethod(Selector Sel, bool isInstance) const {
   // Since instance & class methods can have the same name, the loop below
   // ensures we get the correct method.
   //
@@ -603,29 +603,7 @@ ObjCMethodDecl *ObjCImplDecl::getInstanceMethod(Selector Sel) const {
   for (llvm::tie(Meth, MethEnd) = lookup(Sel);
        Meth != MethEnd; ++Meth) {
     ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*Meth);
-    if (MD && MD->isInstanceMethod())
-      return MD;
-  }
-  return 0;
-}
-
-// getClassMethod - This method returns an instance method by looking in
-// the class implementation. Unlike interfaces, we don't look outside the
-// implementation.
-ObjCMethodDecl *ObjCImplDecl::getClassMethod(Selector Sel) const {
-  // Since instance & class methods can have the same name, the loop below
-  // ensures we get the correct method.
-  //
-  // @interface Whatever
-  // - (int) class_method;
-  // + (float) class_method;
-  // @end
-  //
-  lookup_const_iterator Meth, MethEnd;
-  for (llvm::tie(Meth, MethEnd) = lookup(Sel);
-       Meth != MethEnd; ++Meth) {
-    ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*Meth);
-    if (MD && MD->isClassMethod())
+    if (MD && MD->isInstanceMethod() == isInstance)
       return MD;
   }
   return 0;