]> granicus.if.org Git - clang/commitdiff
Implement ObjCMethodDecl::getCanonicalDecl().
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 28 Jul 2009 05:11:17 +0000 (05:11 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Tue, 28 Jul 2009 05:11:17 +0000 (05:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77298 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/DeclObjC.h
lib/AST/DeclObjC.cpp

index 6dfbcfd00c090280741fde39d22b20052f077ff4..2a1b826bad81546300c63f5175c0e4f17cecb638 100644 (file)
@@ -173,7 +173,9 @@ public:
                                 bool isVariadic = false,
                                 bool isSynthesized = false,
                                 ImplementationControl impControl = None);
-  
+
+  virtual ObjCMethodDecl *getCanonicalDecl();
+
   ObjCDeclQualifier getObjCDeclQualifier() const {
     return ObjCDeclQualifier(objcDeclQualifier);
   }
index 0a284816d8cd179515daad09d25a97be5f72432d..125c94194cbda861ef0d46fb74d043febd53c1b1 100644 (file)
@@ -247,6 +247,26 @@ ObjCMethodDecl *ObjCMethodDecl::getNextRedeclaration() {
   return Redecl ? Redecl : this;
 }
 
+ObjCMethodDecl *ObjCMethodDecl::getCanonicalDecl() {
+  Decl *CtxD = cast<Decl>(getDeclContext());
+
+  if (ObjCImplementationDecl *ImplD = dyn_cast<ObjCImplementationDecl>(CtxD)) {
+    if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface())
+      if (ObjCMethodDecl *MD = IFD->getMethod(getSelector(),
+                                              isInstanceMethod()))
+        return MD;
+
+  } else if (ObjCCategoryImplDecl *CImplD =
+               dyn_cast<ObjCCategoryImplDecl>(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;