[cfe-commits] r76512 - in /cfe/trunk: include/clang/AST/DeclObjC.h lib/AST/DeclObjC.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Mon Jul 20 17:06:37 PDT 2009


Author: akirtzidis
Date: Mon Jul 20 19:06:36 2009
New Revision: 76512

URL: http://llvm.org/viewvc/llvm-project?rev=76512&view=rev
Log:
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.

Modified:
    cfe/trunk/include/clang/AST/DeclObjC.h
    cfe/trunk/lib/AST/DeclObjC.cpp

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=76512&r1=76511&r2=76512&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Mon Jul 20 19:06:36 2009
@@ -154,7 +154,12 @@
     EndLoc(endLoc), Body(0), SelfDecl(0), CmdDecl(0) {}
 
   virtual ~ObjCMethodDecl() {}
-  
+
+  /// \brief A definition will return its interface declaration.
+  /// An interface declaration will return its definition.
+  /// Otherwise it will return itself.
+  virtual ObjCMethodDecl *getNextRedeclaration();
+
 public:
   
   /// Destroy - Call destructors and release memory.

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=76512&r1=76511&r2=76512&view=diff

==============================================================================
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Mon Jul 20 19:06:36 2009
@@ -272,6 +272,30 @@
   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;





More information about the cfe-commits mailing list