From 94a5c3334bba3cc8cd1da85ba1118bc2c080add9 Mon Sep 17 00:00:00 2001 From: Steve Naroff Date: Wed, 19 Dec 2007 22:27:04 +0000 Subject: [PATCH] Various tweaks to the get/lookup instance/class method API's. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45224 91177308-0d34-0410-b5e6-96231b3b80d8 --- AST/Decl.cpp | 36 ++++++++++++++-------------- Sema/SemaDeclObjC.cpp | 8 +++---- Sema/SemaExpr.cpp | 2 +- include/clang/AST/DeclObjC.h | 46 ++++++++++++++++++------------------ 4 files changed, 46 insertions(+), 46 deletions(-) diff --git a/AST/Decl.cpp b/AST/Decl.cpp index 385a82944a..4310e23925 100644 --- a/AST/Decl.cpp +++ b/AST/Decl.cpp @@ -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; } } diff --git a/Sema/SemaDeclObjC.cpp b/Sema/SemaDeclObjC.cpp index 946d12f5c0..3f95968000 100644 --- a/Sema/SemaDeclObjC.cpp +++ b/Sema/SemaDeclObjC.cpp @@ -855,20 +855,20 @@ Sema::DeclTy *Sema::ActOnMethodDeclaration( if (ObjcImplementationDecl *ImpDecl = dyn_cast(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(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); } } diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp index bf5d71fd08..53049c6dec 100644 --- a/Sema/SemaExpr.cpp +++ b/Sema/SemaExpr.cpp @@ -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) diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 3ff7746204..ac9862581b 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -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::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; } -- 2.40.0