diff options
Diffstat (limited to 'clang/tools/libclang/CIndex.cpp')
| -rw-r--r-- | clang/tools/libclang/CIndex.cpp | 38 |
1 files changed, 10 insertions, 28 deletions
diff --git a/clang/tools/libclang/CIndex.cpp b/clang/tools/libclang/CIndex.cpp index 525c5fc0f56..33feadfdf1b 100644 --- a/clang/tools/libclang/CIndex.cpp +++ b/clang/tools/libclang/CIndex.cpp @@ -297,12 +297,6 @@ void CursorVisitor::visitDeclsFromFileRegion(FileID File, CurDC = dyn_cast<DeclContext>(D); - // We handle forward decls via ObjCClassDecl. - if (ObjCInterfaceDecl *InterD = dyn_cast<ObjCInterfaceDecl>(D)) { - if (!InterD->isThisDeclarationADefinition()) - continue; - } - if (TagDecl *TD = dyn_cast<TagDecl>(D)) if (!TD->isFreeStanding()) continue; @@ -1004,6 +998,11 @@ bool CursorVisitor::VisitObjCPropertyDecl(ObjCPropertyDecl *PD) { } bool CursorVisitor::VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) { + if (!D->isThisDeclarationADefinition()) { + // Forward declaration is treated like a reference. + return Visit(MakeCursorObjCClassRef(D, D->getLocation(), TU)); + } + // Issue callbacks for super class. if (D->getSuperClass() && Visit(MakeCursorObjCSuperClassRef(D->getSuperClass(), @@ -1058,13 +1057,6 @@ bool CursorVisitor::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D) { return false; } -bool CursorVisitor::VisitObjCClassDecl(ObjCClassDecl *D) { - if (Visit(MakeCursorObjCClassRef(D->getForwardInterfaceDecl(), - D->getNameLoc(), TU))) - return true; - return false; -} - bool CursorVisitor::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *PD) { if (ObjCIvarDecl *Ivar = PD->getPropertyIvarDecl()) return Visit(MakeCursorMemberRef(Ivar, PD->getPropertyIvarDeclLoc(), TU)); @@ -3890,8 +3882,6 @@ CXCursor clang_getCursorReferenced(CXCursor C) { return clang_getNullCursor(); if (UsingDecl *Using = dyn_cast<UsingDecl>(D)) return MakeCursorOverloadedDeclRef(Using, D->getLocation(), tu); - if (ObjCClassDecl *Classes = dyn_cast<ObjCClassDecl>(D)) - return MakeCursorOverloadedDeclRef(Classes, D->getLocation(), tu); if (ObjCForwardProtocolDecl *Protocols = dyn_cast<ObjCForwardProtocolDecl>(D)) return MakeCursorOverloadedDeclRef(Protocols, D->getLocation(), tu); @@ -4140,19 +4130,20 @@ CXCursor clang_getCursorDefinition(CXCursor C) { return C; return clang_getNullCursor(); - case Decl::ObjCInterface: + case Decl::ObjCInterface: { // There are two notions of a "definition" for an Objective-C // class: the interface and its implementation. When we resolved a // reference to an Objective-C class, produce the @interface as // the definition; when we were provided with the interface, // produce the @implementation as the definition. + ObjCInterfaceDecl *IFace = cast<ObjCInterfaceDecl>(D); if (WasReference) { - if (ObjCInterfaceDecl *Def = cast<ObjCInterfaceDecl>(D)->getDefinition()) + if (ObjCInterfaceDecl *Def = IFace->getDefinition()) return MakeCXCursor(Def, TU); - } else if (ObjCImplementationDecl *Impl - = cast<ObjCInterfaceDecl>(D)->getImplementation()) + } else if (ObjCImplementationDecl *Impl = IFace->getImplementation()) return MakeCXCursor(Impl, TU); return clang_getNullCursor(); + } case Decl::ObjCProperty: // FIXME: We don't really know where to find the @@ -4171,10 +4162,6 @@ CXCursor clang_getCursorDefinition(CXCursor C) { return MakeCursorOverloadedDeclRef(cast<ObjCForwardProtocolDecl>(D), D->getLocation(), TU); - case Decl::ObjCClass: - return MakeCursorOverloadedDeclRef(cast<ObjCClassDecl>(D), D->getLocation(), - TU); - case Decl::Friend: if (NamedDecl *Friend = cast<FriendDecl>(D)->getFriendDecl()) return clang_getCursorDefinition(MakeCXCursor(Friend, TU)); @@ -4230,8 +4217,6 @@ unsigned clang_getNumOverloadedDecls(CXCursor C) { Decl *D = Storage.get<Decl*>(); if (UsingDecl *Using = dyn_cast<UsingDecl>(D)) return Using->shadow_size(); - if (isa<ObjCClassDecl>(D)) - return 1; if (ObjCForwardProtocolDecl *Protocols =dyn_cast<ObjCForwardProtocolDecl>(D)) return Protocols->protocol_size(); @@ -4261,8 +4246,6 @@ CXCursor clang_getOverloadedDecl(CXCursor cursor, unsigned index) { std::advance(Pos, index); return MakeCXCursor(cast<UsingShadowDecl>(*Pos)->getTargetDecl(), TU); } - if (ObjCClassDecl *Classes = dyn_cast<ObjCClassDecl>(D)) - return MakeCXCursor(Classes->getForwardInterfaceDecl(), TU); if (ObjCForwardProtocolDecl *Protocols = dyn_cast<ObjCForwardProtocolDecl>(D)) return MakeCXCursor(Protocols->protocol_begin()[index], TU); @@ -5191,7 +5174,6 @@ static CXLanguageKind getDeclLanguage(const Decl *D) { case Decl::ObjCAtDefsField: case Decl::ObjCCategory: case Decl::ObjCCategoryImpl: - case Decl::ObjCClass: case Decl::ObjCCompatibleAlias: case Decl::ObjCForwardProtocol: case Decl::ObjCImplementation: |

