From f390c43c3c63f2ff9aa51e9d6df1d3c72ccbc91a Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Tue, 28 Jul 2009 05:11:17 +0000 Subject: Implement ObjCMethodDecl::getCanonicalDecl(). llvm-svn: 77298 --- clang/include/clang/AST/DeclObjC.h | 4 +++- clang/lib/AST/DeclObjC.cpp | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'clang') diff --git a/clang/include/clang/AST/DeclObjC.h b/clang/include/clang/AST/DeclObjC.h index 6dfbcfd00c0..2a1b826bad8 100644 --- a/clang/include/clang/AST/DeclObjC.h +++ b/clang/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/clang/lib/AST/DeclObjC.cpp b/clang/lib/AST/DeclObjC.cpp index 0a284816d8c..125c94194cb 100644 --- a/clang/lib/AST/DeclObjC.cpp +++ b/clang/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; -- cgit v1.2.3