[cfe-commits] r44926 - in /cfe/trunk: AST/Decl.cpp include/clang/AST/DeclObjC.h

Chris Lattner sabre at nondot.org
Tue Dec 11 23:30:06 PST 2007


Author: lattner
Date: Wed Dec 12 01:30:05 2007
New Revision: 44926

URL: http://llvm.org/viewvc/llvm-project?rev=44926&view=rev
Log:
start cleaning up interfaces for objc bits and pieces by switching to an
iterator interface.

Modified:
    cfe/trunk/AST/Decl.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=44926&r1=44925&r2=44926&view=diff

==============================================================================
--- cfe/trunk/AST/Decl.cpp (original)
+++ cfe/trunk/AST/Decl.cpp Wed Dec 12 01:30:05 2007
@@ -406,8 +406,8 @@
   return NULL;
 }
 
-// lookupInstanceMethod - This method returns an instance method by looking in
-// the class, it's categories, and it's super classes (using a linear search).
+/// lookupInstanceMethod - This method returns an instance method by looking in
+/// the class, it's categories, and it's super classes (using a linear search).
 ObjcMethodDecl *ObjcInterfaceDecl::lookupInstanceMethod(Selector &Sel) {
   ObjcInterfaceDecl* ClassDecl = this;
   while (ClassDecl != NULL) {
@@ -488,24 +488,20 @@
   return NULL;
 }
 
-// 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 *const*methods = getInstanceMethods();
-  int methodCount = getNumInstanceMethods();
-  for (int i = 0; i < methodCount; ++i) {
-    if (methods[i]->getSelector() == Sel) {
-      return methods[i];
-    }
-  }
+/// 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) {
+  for (instmeth_iterator I = instmeth_begin(), E = instmeth_end(); I != E; ++I)
+    if ((*I)->getSelector() == Sel)
+      return *I;
   return NULL;
 }
 
-// lookupClassMethod - This method returns an instance method by looking in
-// the class implementation. Unlike interfaces, we don't look outside the
-// implementation.
-ObjcMethodDecl *ObjcImplementationDecl::lookupClassMethod(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 *const*methods = getClassMethods();
   int methodCount = getNumClassMethods();
   for (int i = 0; i < methodCount; ++i) {

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

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Wed Dec 12 01:30:05 2007
@@ -589,12 +589,34 @@
   }
   int getNumClassMethods() const { return ClassMethods.size(); }
 
-  ObjcMethodDecl *lookupInstanceMethod(Selector &Sel);
-  ObjcMethodDecl *lookupClassMethod(Selector &Sel);
-  
   ObjcIvarDecl **getImplDeclIVars() const { return Ivars; }
   int getImplDeclNumIvars() const { return NumIvars; }
-    
+  
+  
+  typedef llvm::SmallVector<ObjcMethodDecl*, 32>::const_iterator
+       instmeth_iterator;
+  instmeth_iterator instmeth_begin() const { return InstanceMethods.begin(); }
+  instmeth_iterator instmeth_end() const { return InstanceMethods.end(); }
+
+  typedef llvm::SmallVector<ObjcMethodDecl*, 32>::const_iterator
+    classmeth_iterator;
+  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);
+  
+  /// 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);
+  
+  typedef ObjcIvarDecl * const *ivar_iterator;
+  ivar_iterator ivar_begin() const { return Ivars; }
+  ivar_iterator ivar_end() const { return Ivars+NumIvars; }
+  
   static bool classof(const Decl *D) {
     return D->getKind() == ObjcImplementation;
   }





More information about the cfe-commits mailing list