]> granicus.if.org Git - clang/commitdiff
Various tweaks to the get/lookup instance/class method API's.
authorSteve Naroff <snaroff@apple.com>
Wed, 19 Dec 2007 22:27:04 +0000 (22:27 +0000)
committerSteve Naroff <snaroff@apple.com>
Wed, 19 Dec 2007 22:27:04 +0000 (22:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45224 91177308-0d34-0410-b5e6-96231b3b80d8

AST/Decl.cpp
Sema/SemaDeclObjC.cpp
Sema/SemaExpr.cpp
include/clang/AST/DeclObjC.h

index 385a82944a55b2398b81a7638f51223ecc5fa040..4310e2392544158fbe73dbdd1d27758b9b806c5b 100644 (file)
@@ -407,25 +407,25 @@ ObjcIvarDecl *ObjcInterfaceDecl::lookupInstanceVariable(
 
 /// 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 @@ ObjcMethodDecl *ObjcInterfaceDecl::lookupInstanceMethod(Selector &Sel) {
 
 // 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 @@ ObjcMethodDecl *ObjcInterfaceDecl::lookupClassMethod(Selector &Sel) {
 /// 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 @@ ObjcMethodDecl *ObjcImplementationDecl::lookupInstanceMethod(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 *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 @@ ObjcMethodDecl *ObjcImplementationDecl::lookupClassMethod(Selector Sel) {
 // 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 @@ ObjcMethodDecl *ObjcCategoryImplDecl::lookupInstanceMethod(Selector &Sel) {
 // 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 @@ ObjcMethodDecl *ObjcCategoryImplDecl::lookupClassMethod(Selector &Sel) {
 
 // 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 @@ ObjcMethodDecl *ObjcProtocolDecl::lookupInstanceMethod(Selector &Sel) {
 
 // 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;
     }
   }
index 946d12f5c068a233a60623e033b407dda37fd82f..3f959680001ee355cbe3a2348344ba876a407ea7 100644 (file)
@@ -855,20 +855,20 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration(
   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);
     }
   }
index bf5d71fd080314ca40d6a7ad8e61698e1c46bcbf..53049c6dec9c95c9a8272f8daee97434c60bb820 100644 (file)
@@ -2341,7 +2341,7 @@ Sema::ExprResult Sema::ActOnInstanceMessage(
       // 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)
index 3ff7746204dc35799475201e0e63e26de6ac7b7c..ac9862581ba75729ed28a327be5a32631dfcfd8f 100644 (file)
@@ -278,7 +278,7 @@ public:
                                        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 @@ public:
        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 @@ public:
     }
        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 @@ public:
   }
 
   // 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 @@ public:
        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 @@ public:
        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 @@ public:
   }
 
   // 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 @@ public:
        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 @@ public:
   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 @@ public:
   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; }