From 98c16b8b4fe7bb26b17a479d6872e390816e57d4 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Tue, 24 Jan 2012 19:40:15 +0000 Subject: [PATCH] [libclang] When calling clang_getCursorReferenced on a class or protocol forward reference, do give an interface or protocol cursor back, don't give an 'UnexposedDecl' one. rdar://10743193 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148848 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/libclang/CIndex.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index db84ccdce6..fe4e373e8a 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -3918,14 +3918,23 @@ CXCursor clang_getCursorReferenced(CXCursor C) { return MakeCXCursor(getCursorObjCSuperClassRef(C).first, tu); case CXCursor_ObjCProtocolRef: { - return MakeCXCursor(getCursorObjCProtocolRef(C).first, tu); + ObjCProtocolDecl *Prot = getCursorObjCProtocolRef(C).first; + if (ObjCProtocolDecl *Def = Prot->getDefinition()) + return MakeCXCursor(Def, tu); + + CXCursor C = MakeCXCursor(Prot, tu); + C.kind = CXCursor_ObjCProtocolDecl; // override "Unexposed". + return C; + } case CXCursor_ObjCClassRef: { ObjCInterfaceDecl *Class = getCursorObjCClassRef(C).first; if (ObjCInterfaceDecl *Def = Class->getDefinition()) return MakeCXCursor(Def, tu); - return MakeCXCursor(Class, tu); + CXCursor C = MakeCXCursor(Class, tu); + C.kind = CXCursor_ObjCInterfaceDecl; // override "Unexposed". + return C; } case CXCursor_TypeRef: @@ -3960,7 +3969,6 @@ CXCursor clang_getCursorReferenced(CXCursor C) { default: // We would prefer to enumerate all non-reference cursor kinds here. llvm_unreachable("Unhandled reference cursor kind"); - } } } -- 2.40.0