From: Argyrios Kyrtzidis Date: Tue, 28 Jul 2009 05:11:05 +0000 (+0000) Subject: -Add ObjCCategoryImplDecl::getCategoryClass() which returns the category interface... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4292073a858f72769fa405b48390620c8932f8ae;p=clang -Add ObjCCategoryImplDecl::getCategoryClass() which returns the category interface decl. -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 --- diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index f21d913e63..6dfbcfd00c 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -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 diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 503bc7052d..0a284816d8 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -233,9 +233,15 @@ ObjCMethodDecl *ObjCMethodDecl::getNextRedeclaration() { if (ObjCCategoryImplDecl *ImplD = Ctx.getObjCImplementation(CD)) Redecl = ImplD->getMethod(getSelector(), isInstanceMethod()); - } else if (ObjCImplDecl *ImplD = dyn_cast(CtxD)) { + } else if (ObjCImplementationDecl *ImplD = + dyn_cast(CtxD)) { if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface()) Redecl = IFD->getMethod(getSelector(), isInstanceMethod()); + + } else if (ObjCCategoryImplDecl *CImplD = + dyn_cast(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.