Some refactoring of recent code. No functionality change.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66041 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 80120a7..9266e48 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -211,8 +211,9 @@
 
 // Helper method for ActOnClassMethod/ActOnInstanceMethod.
 // Will search "local" class/category implementations for a method decl.
+// If failed, then we search in class's root for an instance method.
 // Returns 0 if no method is found.
-ObjCMethodDecl *Sema::LookupPrivateMethod(Selector Sel,
+ObjCMethodDecl *Sema::LookupPrivateOrRootMethod(Selector Sel,
                                           ObjCInterfaceDecl *ClassDecl) {
   ObjCMethodDecl *Method = 0;
   
@@ -227,6 +228,15 @@
         Method = ObjCCategoryImpls[i]->getClassMethod(Sel);
     }
   }
+  // Before we give up, check if the selector is an instance method.
+  // But only in the root. This matches gcc's behaviour and what the
+  // runtime expects.
+  if (!Method) {
+    ObjCInterfaceDecl *Root = ClassDecl;
+    while (Root->getSuperClass())
+      Root = Root->getSuperClass();
+    Method = Root->lookupInstanceMethod(Sel);
+  }
   return Method;
 }
 
@@ -311,17 +321,7 @@
   
   // If we have an implementation in scope, check "private" methods.
   if (!Method)
-    Method = LookupPrivateMethod(Sel, ClassDecl);
-
-  // Before we give up, check if the selector is an instance method.
-  // But only in the root. This matches gcc's behaviour and what the
-  // runtime expects.
-  if (!Method) {
-    ObjCInterfaceDecl *Root = ClassDecl;
-    while (Root->getSuperClass())
-      Root = Root->getSuperClass(); 
-    Method = Root->lookupInstanceMethod(Sel);
-  }
+    Method = LookupPrivateOrRootMethod(Sel, ClassDecl);
 
   if (Method && DiagnoseUseOfDecl(Method, receiverLoc))
     return true;
@@ -405,16 +405,7 @@
         Method = ClassDecl->lookupClassMethod(Sel);
         
         if (!Method)
-          Method = LookupPrivateMethod(Sel, ClassDecl);
-        // Before we give up, check if the selector is an instance method.
-        // But only in the root. This matches gcc's behaviour and what the
-        // runtime expects.
-        if (!Method) {
-          ObjCInterfaceDecl *Root = ClassDecl;
-          while (Root->getSuperClass())
-            Root = Root->getSuperClass();
-          Method = Root->lookupInstanceMethod(Sel);
-        }
+          Method = LookupPrivateOrRootMethod(Sel, ClassDecl);
       }
       if (Method && DiagnoseUseOfDecl(Method, receiverLoc))
         return true;