From e2f854ddd365e6837cef3e1a1b7621b32200fc71 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Fri, 15 Jul 2011 22:27:18 +0000 Subject: [PATCH] Revert r135304 and apply fix in clang_getCanonicalCursor per Doug's, Fariborz's comments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135314 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/AST/DeclObjC.h | 6 ------ tools/libclang/CIndex.cpp | 7 ++++++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/include/clang/AST/DeclObjC.h b/include/clang/AST/DeclObjC.h index 88877cfe0b..d318fc27a8 100644 --- a/include/clang/AST/DeclObjC.h +++ b/include/clang/AST/DeclObjC.h @@ -1122,12 +1122,6 @@ protected: ClassInterface(classInterface) {} public: - virtual Decl *getCanonicalDecl() { - if (Decl *interface = getClassInterface()) - return interface; - return this; - } - const ObjCInterfaceDecl *getClassInterface() const { return ClassInterface; } ObjCInterfaceDecl *getClassInterface() { return ClassInterface; } void setClassInterface(ObjCInterfaceDecl *IFace); diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 756d570d91..6f001d5381 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -4141,8 +4141,13 @@ CXCursor clang_getCanonicalCursor(CXCursor C) { if (!clang_isDeclaration(C.kind)) return C; - if (Decl *D = getCursorDecl(C)) + if (Decl *D = getCursorDecl(C)) { + if (ObjCImplDecl *ImplD = dyn_cast(D)) + if (ObjCInterfaceDecl *IFD = ImplD->getClassInterface()) + return MakeCXCursor(IFD, getCursorTU(C)); + return MakeCXCursor(D->getCanonicalDecl(), getCursorTU(C)); + } return C; } -- 2.40.0