]> granicus.if.org Git - clang/commitdiff
-Add ObjCCategoryImplDecl::getCategoryClass() which returns the category interface...
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 28 Jul 2009 05:11:05 +0000 (05:11 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 28 Jul 2009 05:11:05 +0000 (05:11 +0000)
-Correct ObjCMethodDecl::getNextRedeclaration(); A method in a ObjCCategoryImplDecl should point to
a method in the associated ObjCCategoryDecl, not the ObjCInterfaceDecl.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77297 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp

index f21d913e6332abddfcf6bdf3f1b267ac7f09c9ef..6dfbcfd00c090280741fde39d22b20052f077ff4 100644 (file)
@@ -918,6 +918,8 @@ public:
     return Id; 
   }
   void setIdentifier(IdentifierInfo *II) { Id = II; }
+  
+  ObjCCategoryDecl *getCategoryClass() const;
 
   /// getNameAsCString - Get the name of identifier for the class
   /// interface associated with this implementation as a C string
index 503bc7052dc64bf98b501a52a5d9e73dad93d9af..0a284816d8cd179515daad09d25a97be5f72432d 100644 (file)
@@ -233,9 +233,15 @@ ObjCMethodDecl *ObjCMethodDecl::getNextRedeclaration() {
     if (ObjCCategoryImplDecl *ImplD = Ctx.getObjCImplementation(CD))
       Redecl = ImplD->getMethod(getSelector(), isInstanceMethod());
 
-  } else if (ObjCImplDecl *ImplD = dyn_cast<ObjCImplDecl>(CtxD)) {
+  } else if (ObjCImplementationDecl *ImplD =
+               dyn_cast<ObjCImplementationDecl>(CtxD)) {
     if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface())
       Redecl = IFD->getMethod(getSelector(), isInstanceMethod());
+
+  } else if (ObjCCategoryImplDecl *CImplD =
+               dyn_cast<ObjCCategoryImplDecl>(CtxD)) {
+    if (ObjCCategoryDecl *CatD = CImplD->getCategoryClass())
+      Redecl = CatD->getMethod(getSelector(), isInstanceMethod());
   }
 
   return Redecl ? Redecl : this;
@@ -532,6 +538,10 @@ ObjCCategoryImplDecl::Create(ASTContext &C, DeclContext *DC,
   return new (C) ObjCCategoryImplDecl(DC, L, Id, ClassInterface);
 }
 
+ObjCCategoryDecl *ObjCCategoryImplDecl::getCategoryClass() const {
+  return getClassInterface()->FindCategoryDeclaration(getIdentifier());
+}
+
 
 void ObjCImplDecl::addPropertyImplementation(ObjCPropertyImplDecl *property) {
   // FIXME: The context should be correct before we get here.