[cfe-commits] r77091 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp
Argiris Kirtzidis
akyrtzi at gmail.com
Sat Jul 25 15:15:22 PDT 2009
Author: akirtzidis
Date: Sat Jul 25 17:15:22 2009
New Revision: 77091
URL: http://llvm.org/viewvc/llvm-project?rev=77091&view=rev
Log:
Refactor ObjCContainerDecl::getInstanceMethod/getClassMethod into one
ObjCContainerDecl::getMethod.
Avoids code duplication.
Modified:
cfe/trunk/include/clang/AST/DeclObjC.h
cfe/trunk/lib/AST/DeclObjC.cpp
Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=77091&r1=77090&r2=77091&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Sat Jul 25 17:15:22 2009
@@ -333,13 +333,14 @@
}
// Get the local instance/class method declared in this interface.
- ObjCMethodDecl *getInstanceMethod(Selector Sel) const;
- ObjCMethodDecl *getClassMethod(Selector Sel) const;
- ObjCIvarDecl *getIvarDecl(IdentifierInfo *Id) const;
-
- ObjCMethodDecl *getMethod(Selector Sel, bool isInstance) const {
- return isInstance ? getInstanceMethod(Sel) : getClassMethod(Sel);
+ ObjCMethodDecl *getMethod(Selector Sel, bool isInstance) const;
+ ObjCMethodDecl *getInstanceMethod(Selector Sel) const {
+ return getMethod(Sel, true/*isInstance*/);
+ }
+ ObjCMethodDecl *getClassMethod(Selector Sel) const {
+ return getMethod(Sel, false/*isInstance*/);
}
+ ObjCIvarDecl *getIvarDecl(IdentifierInfo *Id) const;
ObjCPropertyDecl *FindPropertyDeclaration(IdentifierInfo *PropertyId) const;
Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=77091&r1=77090&r2=77091&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Sat Jul 25 17:15:22 2009
@@ -54,9 +54,9 @@
return 0;
}
-// Get the local instance method declared in this interface.
+// Get the local instance/class method declared in this interface.
ObjCMethodDecl *
-ObjCContainerDecl::getInstanceMethod(Selector Sel) const {
+ObjCContainerDecl::getMethod(Selector Sel, bool isInstance) const {
// Since instance & class methods can have the same name, the loop below
// ensures we get the correct method.
//
@@ -68,27 +68,7 @@
lookup_const_iterator Meth, MethEnd;
for (llvm::tie(Meth, MethEnd) = lookup(Sel); Meth != MethEnd; ++Meth) {
ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*Meth);
- if (MD && MD->isInstanceMethod())
- return MD;
- }
- return 0;
-}
-
-// Get the local class method declared in this interface.
-ObjCMethodDecl *
-ObjCContainerDecl::getClassMethod(Selector Sel) const {
- // Since instance & class methods can have the same name, the loop below
- // ensures we get the correct method.
- //
- // @interface Whatever
- // - (int) class_method;
- // + (float) class_method;
- // @end
- //
- lookup_const_iterator Meth, MethEnd;
- for (llvm::tie(Meth, MethEnd) = lookup(Sel); Meth != MethEnd; ++Meth) {
- ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(*Meth);
- if (MD && MD->isClassMethod())
+ if (MD && MD->isInstanceMethod() == isInstance)
return MD;
}
return 0;
More information about the cfe-commits
mailing list