From: Argyrios Kyrtzidis Date: Tue, 28 Jul 2009 05:11:17 +0000 (+0000) Subject: Implement ObjCMethodDecl::getCanonicalDecl(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e7f9d301a10b4b3223e91d9be4362b44cba0a212;p=clang Implement ObjCMethodDecl::getCanonicalDecl(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77298 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 6dfbcfd00c..2a1b826bad 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -173,7 +173,9 @@ public: bool isVariadic = false, bool isSynthesized = false, ImplementationControl impControl = None); - + + virtual ObjCMethodDecl *getCanonicalDecl(); + ObjCDeclQualifier getObjCDeclQualifier() const { return ObjCDeclQualifier(objcDeclQualifier); } diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 0a284816d8..125c94194c 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -247,6 +247,26 @@ ObjCMethodDecl *ObjCMethodDecl::getNextRedeclaration() { return Redecl ? Redecl : this; } +ObjCMethodDecl *ObjCMethodDecl::getCanonicalDecl() { + Decl *CtxD = cast(getDeclContext()); + + if (ObjCImplementationDecl *ImplD = dyn_cast(CtxD)) { + if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface()) + if (ObjCMethodDecl *MD = IFD->getMethod(getSelector(), + isInstanceMethod())) + return MD; + + } else if (ObjCCategoryImplDecl *CImplD = + dyn_cast(CtxD)) { + if (ObjCCategoryDecl *CatD = CImplD->getCategoryClass()) + if (ObjCMethodDecl *MD = CatD->getMethod(getSelector(), + isInstanceMethod())) + return MD; + } + + return this; +} + void ObjCMethodDecl::createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *OID) { QualType selfTy;