Remove the ObjCCategoryImpls vector from Sema class.
Use ObjCInterfaceDecl::getCategoryClassMethod() and ObjCInterfaceDecl::getCategoryInstanceMethod() for the same functionality.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76510 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/Sema.h b/lib/Sema/Sema.h
index 1e75bb2..47938dc 100644
--- a/lib/Sema/Sema.h
+++ b/lib/Sema/Sema.h
@@ -185,10 +185,6 @@
   /// us to associate a raw vector type with one of the ext_vector type names.
   /// This is only necessary for issuing pretty diagnostics.
   llvm::SmallVector<TypedefDecl*, 24> ExtVectorDecls;
-
-  /// ObjCCategoryImpls - Maintain a list of category implementations so 
-  /// we can check for duplicates and find local method declarations.
-  llvm::SmallVector<ObjCCategoryImplDecl*, 8> ObjCCategoryImpls;
   
   /// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
   llvm::OwningPtr<CXXFieldCollector> FieldCollector;
diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp
index 89bde81..19cbf09 100644
--- a/lib/Sema/SemaDeclObjC.cpp
+++ b/lib/Sema/SemaDeclObjC.cpp
@@ -638,8 +638,6 @@
     } else
       CatIDecl->setImplementation(CDecl);
   }
-
-  ObjCCategoryImpls.push_back(CDecl);
   
   CheckObjCDeclScope(CDecl);
   return DeclPtrTy::make(CDecl);
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 2f47c79..145a928 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -2250,12 +2250,8 @@
         Setter = FindMethodInNestedImplementations(IFace, SetterSel);
       }
       // Look through local category implementations associated with the class.
-      if (!Setter) {
-        for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Setter; i++) {
-          if (ObjCCategoryImpls[i]->getClassInterface() == IFace)
-            Setter = ObjCCategoryImpls[i]->getClassMethod(SetterSel);
-        }
-      }
+      if (!Setter)
+        Setter = IFace->getCategoryClassMethod(SetterSel);
 
       if (Setter && DiagnoseUseOfDecl(Setter, MemberLoc))
         return ExprError();
@@ -2431,12 +2427,8 @@
       Getter = FindMethodInNestedImplementations(IFace, Sel);
 
     // Look through local category implementations associated with the class.
-    if (!Getter) {
-      for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Getter; i++) {
-        if (ObjCCategoryImpls[i]->getClassInterface() == IFace)
-          Getter = ObjCCategoryImpls[i]->getInstanceMethod(Sel);
-      }
-    }
+    if (!Getter)
+      Getter = IFace->getCategoryInstanceMethod(Sel);
     if (Getter) {
       // Check if we can reference this property.
       if (DiagnoseUseOfDecl(Getter, MemberLoc))
@@ -2454,12 +2446,8 @@
       Setter = FindMethodInNestedImplementations(IFace, SetterSel);
     }
     // Look through local category implementations associated with the class.
-    if (!Setter) {
-      for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Setter; i++) {
-        if (ObjCCategoryImpls[i]->getClassInterface() == IFace)
-          Setter = ObjCCategoryImpls[i]->getInstanceMethod(SetterSel);
-      }
-    }
+    if (!Setter)
+      Setter = IFace->getCategoryInstanceMethod(SetterSel);
 
     if (Setter && DiagnoseUseOfDecl(Setter, MemberLoc))
       return ExprError();
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 141cd80..068b386 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -245,12 +245,8 @@
       Method = ImpDecl->getClassMethod(Sel);
     
     // Look through local category implementations associated with the class.
-    if (!Method) {
-      for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Method; i++) {
-        if (ObjCCategoryImpls[i]->getClassInterface() == ClassDecl)
-          Method = ObjCCategoryImpls[i]->getClassMethod(Sel);
-      }
-    }
+    if (!Method)
+      Method = ClassDecl->getCategoryClassMethod(Sel);
     
     // Before we give up, check if the selector is an instance method.
     // But only in the root. This matches gcc's behaviour and what the
@@ -277,12 +273,8 @@
       Method = ImpDecl->getInstanceMethod(Sel);
     
     // Look through local category implementations associated with the class.
-    if (!Method) {
-      for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Method; i++) {
-        if (ObjCCategoryImpls[i]->getClassInterface() == ClassDecl)
-          Method = ObjCCategoryImpls[i]->getInstanceMethod(Sel);
-      }
-    }
+    if (!Method)
+      Method = ClassDecl->getCategoryInstanceMethod(Sel);
     ClassDecl = ClassDecl->getSuperClass();
   }
   return Method;
@@ -330,12 +322,8 @@
           Setter = ImpDecl->getClassMethod(SetterSel);
   }
   // Look through local category implementations associated with the class.
-  if (!Setter) {
-    for (unsigned i = 0; i < ObjCCategoryImpls.size() && !Setter; i++) {
-      if (ObjCCategoryImpls[i]->getClassInterface() == IFace)
-        Setter = ObjCCategoryImpls[i]->getClassMethod(SetterSel);
-    }
-  }
+  if (!Setter)
+    Setter = IFace->getCategoryClassMethod(SetterSel);
 
   if (Setter && DiagnoseUseOfDecl(Setter, propertyNameLoc))
     return ExprError();