[cfe-commits] r45224 - in /cfe/trunk: AST/Decl.cpp Sema/SemaDeclObjC.cpp Sema/SemaExpr.cpp include/clang/AST/DeclObjC.h

Steve Naroff snaroff at apple.com
Wed Dec 19 14:27:04 PST 2007


Author: snaroff
Date: Wed Dec 19 16:27:04 2007
New Revision: 45224

URL: http://llvm.org/viewvc/llvm-project?rev=45224&view=rev
Log:

Various tweaks to the get/lookup instance/class method API's.


Modified:
    cfe/trunk/AST/Decl.cpp
    cfe/trunk/Sema/SemaDeclObjC.cpp
    cfe/trunk/Sema/SemaExpr.cpp
    cfe/trunk/include/clang/AST/DeclObjC.h

Modified: cfe/trunk/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/AST/Decl.cpp?rev=45224&r1=45223&r2=45224&view=diff

==============================================================================
--- cfe/trunk/AST/Decl.cpp (original)
+++ cfe/trunk/AST/Decl.cpp Wed Dec 19 16:27:04 2007
@@ -407,25 +407,25 @@
 
 /// lookupInstanceMethod - This method returns an instance method by looking in
 /// the class, its categories, and its super classes (using a linear search).
-ObjcMethodDecl *ObjcInterfaceDecl::lookupInstanceMethod(Selector &Sel) {
+ObjcMethodDecl *ObjcInterfaceDecl::lookupInstanceMethod(Selector Sel) {
   ObjcInterfaceDecl* ClassDecl = this;
   ObjcMethodDecl *MethodDecl = 0;
   
   while (ClassDecl != NULL) {
-    if ((MethodDecl = ClassDecl->getInstanceMethodForSelector(Sel)))
+    if ((MethodDecl = ClassDecl->getInstanceMethod(Sel)))
       return MethodDecl;
       
     // Didn't find one yet - look through protocols.
     ObjcProtocolDecl **protocols = ClassDecl->getReferencedProtocols();
     int numProtocols = ClassDecl->getNumIntfRefProtocols();
     for (int pIdx = 0; pIdx < numProtocols; pIdx++) {
-      if ((MethodDecl = protocols[pIdx]->getInstanceMethodForSelector(Sel)))
+      if ((MethodDecl = protocols[pIdx]->getInstanceMethod(Sel)))
         return MethodDecl;
     }
     // Didn't find one yet - now look through categories.
     ObjcCategoryDecl *CatDecl = ClassDecl->getCategoryList();
     while (CatDecl) {
-      if ((MethodDecl = CatDecl->getInstanceMethodForSelector(Sel)))
+      if ((MethodDecl = CatDecl->getInstanceMethod(Sel)))
         return MethodDecl;
       CatDecl = CatDecl->getNextClassCategory();
     }
@@ -436,25 +436,25 @@
 
 // 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) {
+ObjcMethodDecl *ObjcInterfaceDecl::lookupClassMethod(Selector Sel) {
   ObjcInterfaceDecl* ClassDecl = this;
   ObjcMethodDecl *MethodDecl = 0;
 
   while (ClassDecl != NULL) {
-    if ((MethodDecl = ClassDecl->getClassMethodForSelector(Sel)))
+    if ((MethodDecl = ClassDecl->getClassMethod(Sel)))
       return MethodDecl;
 
     // Didn't find one yet - look through protocols.
     ObjcProtocolDecl **protocols = ClassDecl->getReferencedProtocols();
     int numProtocols = ClassDecl->getNumIntfRefProtocols();
     for (int pIdx = 0; pIdx < numProtocols; pIdx++) {
-      if ((MethodDecl = protocols[pIdx]->getClassMethodForSelector(Sel)))
+      if ((MethodDecl = protocols[pIdx]->getClassMethod(Sel)))
         return MethodDecl;
     }
     // Didn't find one yet - now look through categories.
     ObjcCategoryDecl *CatDecl = ClassDecl->getCategoryList();
     while (CatDecl) {
-      if ((MethodDecl = CatDecl->getClassMethodForSelector(Sel)))
+      if ((MethodDecl = CatDecl->getClassMethod(Sel)))
         return MethodDecl;
       CatDecl = CatDecl->getNextClassCategory();
     }
@@ -466,7 +466,7 @@
 /// lookupInstanceMethod - This method returns an instance method by looking in
 /// the class implementation. Unlike interfaces, we don't look outside the
 /// implementation.
-ObjcMethodDecl *ObjcImplementationDecl::lookupInstanceMethod(Selector Sel) {
+ObjcMethodDecl *ObjcImplementationDecl::getInstanceMethod(Selector Sel) {
   for (instmeth_iterator I = instmeth_begin(), E = instmeth_end(); I != E; ++I)
     if ((*I)->getSelector() == Sel)
       return *I;
@@ -476,7 +476,7 @@
 /// lookupClassMethod - This method returns a class method by looking in
 /// the class implementation. Unlike interfaces, we don't look outside the
 /// implementation.
-ObjcMethodDecl *ObjcImplementationDecl::lookupClassMethod(Selector Sel) {
+ObjcMethodDecl *ObjcImplementationDecl::getClassMethod(Selector Sel) {
   for (classmeth_iterator I = classmeth_begin(), E = classmeth_end();
        I != E; ++I)
     if ((*I)->getSelector() == Sel)
@@ -487,7 +487,7 @@
 // lookupInstanceMethod - This method returns an instance method by looking in
 // the class implementation. Unlike interfaces, we don't look outside the
 // implementation.
-ObjcMethodDecl *ObjcCategoryImplDecl::lookupInstanceMethod(Selector &Sel) {
+ObjcMethodDecl *ObjcCategoryImplDecl::getInstanceMethod(Selector Sel) {
   for (instmeth_iterator I = instmeth_begin(), E = instmeth_end(); I != E; ++I)
     if ((*I)->getSelector() == Sel)
       return *I;
@@ -497,7 +497,7 @@
 // lookupClassMethod - This method returns an instance method by looking in
 // the class implementation. Unlike interfaces, we don't look outside the
 // implementation.
-ObjcMethodDecl *ObjcCategoryImplDecl::lookupClassMethod(Selector &Sel) {
+ObjcMethodDecl *ObjcCategoryImplDecl::getClassMethod(Selector Sel) {
   for (classmeth_iterator I = classmeth_begin(), E = classmeth_end();
        I != E; ++I)
     if ((*I)->getSelector() == Sel)
@@ -507,17 +507,17 @@
 
 // lookupInstanceMethod - Lookup a instance method in the protocol and protocols
 // it inherited.
-ObjcMethodDecl *ObjcProtocolDecl::lookupInstanceMethod(Selector &Sel) {
+ObjcMethodDecl *ObjcProtocolDecl::lookupInstanceMethod(Selector Sel) {
   ObjcMethodDecl *MethodDecl = NULL;
   
-  if ((MethodDecl = getInstanceMethodForSelector(Sel)))
+  if ((MethodDecl = getInstanceMethod(Sel)))
     return MethodDecl;
     
   if (getNumReferencedProtocols() > 0) {
     ObjcProtocolDecl **RefPDecl = getReferencedProtocols();
     
     for (int i = 0; i < getNumReferencedProtocols(); i++) {
-      if ((MethodDecl = RefPDecl[i]->getInstanceMethodForSelector(Sel)))
+      if ((MethodDecl = RefPDecl[i]->getInstanceMethod(Sel)))
         return MethodDecl;
     }
   }
@@ -526,17 +526,17 @@
 
 // lookupInstanceMethod - Lookup a class method in the protocol and protocols
 // it inherited.
-ObjcMethodDecl *ObjcProtocolDecl::lookupClassMethod(Selector &Sel) {
+ObjcMethodDecl *ObjcProtocolDecl::lookupClassMethod(Selector Sel) {
   ObjcMethodDecl *MethodDecl = NULL;
 
-  if ((MethodDecl = getClassMethodForSelector(Sel)))
+  if ((MethodDecl = getClassMethod(Sel)))
     return MethodDecl;
     
   if (getNumReferencedProtocols() > 0) {
     ObjcProtocolDecl **RefPDecl = getReferencedProtocols();
     
     for (int i = 0; i < getNumReferencedProtocols(); i++) {
-      if ((MethodDecl = RefPDecl[i]->getClassMethodForSelector(Sel)))
+      if ((MethodDecl = RefPDecl[i]->getClassMethod(Sel)))
         return MethodDecl;
     }
   }

Modified: cfe/trunk/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDeclObjC.cpp?rev=45224&r1=45223&r2=45224&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/Sema/SemaDeclObjC.cpp Wed Dec 19 16:27:04 2007
@@ -855,20 +855,20 @@
   if (ObjcImplementationDecl *ImpDecl = 
         dyn_cast<ObjcImplementationDecl>(CDecl)) {
     if (MethodType == tok::minus) {
-      PrevMethod = ImpDecl->lookupInstanceMethod(Sel);
+      PrevMethod = ImpDecl->getInstanceMethod(Sel);
       ImpDecl->addInstanceMethod(ObjcMethod);
     } else {
-      PrevMethod = ImpDecl->lookupClassMethod(Sel);
+      PrevMethod = ImpDecl->getClassMethod(Sel);
       ImpDecl->addClassMethod(ObjcMethod);
     }
   } 
   else if (ObjcCategoryImplDecl *CatImpDecl = 
             dyn_cast<ObjcCategoryImplDecl>(CDecl)) {
     if (MethodType == tok::minus) {
-      PrevMethod = CatImpDecl->lookupInstanceMethod(Sel);
+      PrevMethod = CatImpDecl->getInstanceMethod(Sel);
       CatImpDecl->addInstanceMethod(ObjcMethod);
     } else {
-      PrevMethod = CatImpDecl->lookupClassMethod(Sel);
+      PrevMethod = CatImpDecl->getClassMethod(Sel);
       CatImpDecl->addClassMethod(ObjcMethod);
     }
   }

Modified: cfe/trunk/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaExpr.cpp?rev=45224&r1=45223&r2=45224&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/Sema/SemaExpr.cpp Wed Dec 19 16:27:04 2007
@@ -2341,7 +2341,7 @@
       // If we have an implementation in scope, check "private" methods.
       if (ObjcImplementationDecl *ImpDecl = 
             ObjcImplementations[ClassDecl->getIdentifier()])
-        Method = ImpDecl->lookupInstanceMethod(Sel);
+        Method = ImpDecl->getInstanceMethod(Sel);
 	  // If we still haven't found a method, look in the global pool. This
 	  // behavior isn't very desirable, however we need it for GCC compatibility.
 	  if (!Method)

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=45224&r1=45223&r2=45224&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Dec 19 16:27:04 2007
@@ -278,7 +278,7 @@
                                        ObjcInterfaceDecl *&clsDeclared);
 									   
   // Get the local instance method declared in this interface.
-  ObjcMethodDecl *getInstanceMethodForSelector(Selector &Sel) {
+  ObjcMethodDecl *getInstanceMethod(Selector &Sel) {
     for (instmeth_iterator I = instmeth_begin(), E = instmeth_end(); 
 	     I != E; ++I) {
       if ((*I)->getSelector() == Sel)
@@ -287,7 +287,7 @@
 	return 0;
   }
   // Get the local class method declared in this interface.
-  ObjcMethodDecl *getClassMethodForSelector(Selector &Sel) {
+  ObjcMethodDecl *getClassMethod(Selector &Sel) {
     for (classmeth_iterator I = classmeth_begin(), E = classmeth_end(); 
 	     I != E; ++I) {
       if ((*I)->getSelector() == Sel)
@@ -295,11 +295,10 @@
     }
 	return 0;
   }
-  // Lookup the instance method. First, we search locally. If a method isn't
-  // found, we look through the reference protocols. Lastly, we look categories
-  // defined for this class.
-  ObjcMethodDecl *lookupInstanceMethod(Selector &Sel);
-  ObjcMethodDecl *lookupClassMethod(Selector &Sel);
+  // 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);
 
   // Location information, modeled after the Stmt API. 
   SourceLocation getLocStart() const { return getLocation(); } // '@'interface
@@ -445,7 +444,7 @@
   }
 
   // Get the local instance method declared in this interface.
-  ObjcMethodDecl *getInstanceMethodForSelector(Selector &Sel) {
+  ObjcMethodDecl *getInstanceMethod(Selector &Sel) {
     for (instmeth_iterator I = instmeth_begin(), E = instmeth_end(); 
 	     I != E; ++I) {
       if ((*I)->getSelector() == Sel)
@@ -454,7 +453,7 @@
 	return 0;
   }
   // Get the local class method declared in this interface.
-  ObjcMethodDecl *getClassMethodForSelector(Selector &Sel) {
+  ObjcMethodDecl *getClassMethod(Selector &Sel) {
     for (classmeth_iterator I = classmeth_begin(), E = classmeth_end(); 
 	     I != E; ++I) {
       if ((*I)->getSelector() == Sel)
@@ -463,8 +462,10 @@
 	return 0;
   }
   
-  ObjcMethodDecl *lookupInstanceMethod(Selector &Sel);
-  ObjcMethodDecl *lookupClassMethod(Selector &Sel);
+  // 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);
   
   bool isForwardDecl() const { return isForwardProtoDecl; }
   void setForwardDecl(bool val) { isForwardProtoDecl = val; }
@@ -633,7 +634,7 @@
   }
 
   // Get the local instance method declared in this interface.
-  ObjcMethodDecl *getInstanceMethodForSelector(Selector &Sel) {
+  ObjcMethodDecl *getInstanceMethod(Selector &Sel) {
     for (instmeth_iterator I = instmeth_begin(), E = instmeth_end(); 
 	     I != E; ++I) {
       if ((*I)->getSelector() == Sel)
@@ -642,7 +643,7 @@
 	return 0;
   }
   // Get the local class method declared in this interface.
-  ObjcMethodDecl *getClassMethodForSelector(Selector &Sel) {
+  ObjcMethodDecl *getClassMethod(Selector &Sel) {
     for (classmeth_iterator I = classmeth_begin(), E = classmeth_end(); 
 	     I != E; ++I) {
       if ((*I)->getSelector() == Sel)
@@ -701,8 +702,11 @@
   void addClassMethod(ObjcMethodDecl *method) {
     ClassMethods.push_back(method);
   }    
-  ObjcMethodDecl *lookupInstanceMethod(Selector &Sel);
-  ObjcMethodDecl *lookupClassMethod(Selector &Sel);
+  // Get the instance method definition for this implementation.
+  ObjcMethodDecl *getInstanceMethod(Selector Sel);
+  
+  // Get the class method definition for this implementation.
+  ObjcMethodDecl *getClassMethod(Selector Sel);
 
   typedef llvm::SmallVector<ObjcMethodDecl*, 32>::const_iterator
     instmeth_iterator;
@@ -801,15 +805,11 @@
   classmeth_iterator classmeth_begin() const { return ClassMethods.begin(); }
   classmeth_iterator classmeth_end() const { return ClassMethods.end(); }
   
-  /// lookupInstanceMethod - This method returns an instance method by looking
-  /// in the class implementation. Unlike interfaces, we don't look outside the
-  /// implementation.
-  ObjcMethodDecl *lookupInstanceMethod(Selector Sel);
+  // Get the instance method definition for this implementation.
+  ObjcMethodDecl *getInstanceMethod(Selector Sel);
   
-  /// lookupClassMethod - This method returns a class method by looking in
-  /// the class implementation. Unlike interfaces, we don't look outside the
-  /// implementation.
-  ObjcMethodDecl *lookupClassMethod(Selector Sel);
+  // Get the class method definition for this implementation.
+  ObjcMethodDecl *getClassMethod(Selector Sel);
   
   typedef ObjcIvarDecl * const *ivar_iterator;
   ivar_iterator ivar_begin() const { return Ivars; }





More information about the cfe-commits mailing list