From: Argyrios Kyrtzidis Date: Sat, 4 Feb 2012 01:04:58 +0000 (+0000) Subject: [libclang] Stick to the silly notion that a forward class/protocol X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1836db0f2c7527ac11af0044ab89150f9aaf22e1;p=clang [libclang] Stick to the silly notion that a forward class/protocol declaration is a reference. rdar://10749990 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149733 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index a2c0fb0bdf..675126de09 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -560,6 +560,20 @@ bool CursorVisitor::VisitDeclContext(DeclContext *DC) { if (D->getLexicalDeclContext() != DC) continue; CXCursor Cursor = MakeCXCursor(D, TU, RegionOfInterest); + + // FIXME: ObjCClassRef/ObjCProtocolRef for forward class/protocol + // declarations is a mismatch with the compiler semantics. + if (Cursor.kind == CXCursor_ObjCInterfaceDecl) { + ObjCInterfaceDecl *ID = cast(D); + if (!ID->isThisDeclarationADefinition()) + Cursor = MakeCursorObjCClassRef(ID, ID->getLocation(), TU); + + } else if (Cursor.kind == CXCursor_ObjCProtocolDecl) { + ObjCProtocolDecl *PD = cast(D); + if (!PD->isThisDeclarationADefinition()) + Cursor = MakeCursorObjCProtocolRef(PD, PD->getLocation(), TU); + } + const llvm::Optional &V = shouldVisitCursor(Cursor); if (!V.hasValue()) continue;