diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-21 00:06:36 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2009-07-21 00:06:36 +0000 |
commit | 57ea6bee79cc60ba20c7886b453f40f380dce1b1 (patch) | |
tree | 39f3c47d07a28ea801035c591c85fd2eea185fb3 /lib/AST/DeclObjC.cpp | |
parent | 22cbd2b794676c3b29c2b401c26730ed7047809e (diff) |
Implement the virtual getNextRedeclaration() for ObjCMethodDecl.
If it's in an ObjCContainerDecl, its "redeclaration" is the method definition in the corresponding ObjCImplDecl.
If it's in an ObjCImplDecl, its "redeclaration" is the method in the interface.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76512 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclObjC.cpp')
-rw-r--r-- | lib/AST/DeclObjC.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/AST/DeclObjC.cpp b/lib/AST/DeclObjC.cpp index 7b86bfd195..cd4c5c072e 100644 --- a/lib/AST/DeclObjC.cpp +++ b/lib/AST/DeclObjC.cpp @@ -272,6 +272,30 @@ void ObjCMethodDecl::Destroy(ASTContext &C) { Decl::Destroy(C); } +/// \brief A definition will return its interface declaration. +/// An interface declaration will return its definition. +/// Otherwise it will return itself. +ObjCMethodDecl *ObjCMethodDecl::getNextRedeclaration() { + ASTContext &Ctx = getASTContext(); + ObjCMethodDecl *Redecl = 0; + Decl *CtxD = cast<Decl>(getDeclContext()); + + if (ObjCInterfaceDecl *IFD = dyn_cast<ObjCInterfaceDecl>(CtxD)) { + if (ObjCImplementationDecl *ImplD = Ctx.getObjCImplementation(IFD)) + Redecl = ImplD->getMethod(getSelector(), isInstanceMethod()); + + } else if (ObjCCategoryDecl *CD = dyn_cast<ObjCCategoryDecl>(CtxD)) { + if (ObjCCategoryImplDecl *ImplD = Ctx.getObjCImplementation(CD)) + Redecl = ImplD->getMethod(getSelector(), isInstanceMethod()); + + } else if (ObjCImplDecl *ImplD = dyn_cast<ObjCImplDecl>(CtxD)) { + if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface()) + Redecl = IFD->getMethod(getSelector(), isInstanceMethod()); + } + + return Redecl ? Redecl : this; +} + void ObjCMethodDecl::createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *OID) { QualType selfTy; |