[cfe-commits] r66041 - in /cfe/trunk/lib/Sema: Sema.h SemaExprObjC.cpp

Fariborz Jahanian fjahanian at apple.com
Wed Mar 4 10:15:59 PST 2009


Author: fjahanian
Date: Wed Mar  4 12:15:57 2009
New Revision: 66041

URL: http://llvm.org/viewvc/llvm-project?rev=66041&view=rev
Log:
Some refactoring of recent code. No functionality change.


Modified:
    cfe/trunk/lib/Sema/Sema.h
    cfe/trunk/lib/Sema/SemaExprObjC.cpp

Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=66041&r1=66040&r2=66041&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Wed Mar  4 12:15:57 2009
@@ -1768,8 +1768,9 @@
 
   // Helper method for ActOnClassMethod/ActOnInstanceMethod.
   // Will search "local" class/category implementations for a method decl.
+  // Will also search in class's root looking for instance method.
   // Returns 0 if no method is found.
-  ObjCMethodDecl *LookupPrivateMethod(Selector Sel, ObjCInterfaceDecl *CDecl);
+  ObjCMethodDecl *LookupPrivateOrRootMethod(Selector Sel, ObjCInterfaceDecl *CDecl);
   
   // ActOnClassMessage - used for both unary and keyword messages.
   // ArgExprs is optional - if it is present, the number of expressions

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=66041&r1=66040&r2=66041&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Wed Mar  4 12:15:57 2009
@@ -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;





More information about the cfe-commits mailing list