diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2016-03-03 05:33:54 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2016-03-03 05:33:54 +0000 |
commit | 34a0c1a572de6f0baa3f2d6541f40a1eebc3f4dd (patch) | |
tree | d3e83b4a32b25485aeaac7b3258392a93e8e4401 /clang/lib/Index/IndexDecl.cpp | |
parent | d68a4d6ae0e082e1b1cd404847f3918ecd9e2f74 (diff) | |
download | bcm5719-llvm-34a0c1a572de6f0baa3f2d6541f40a1eebc3f4dd.tar.gz bcm5719-llvm-34a0c1a572de6f0baa3f2d6541f40a1eebc3f4dd.zip |
[index] Report references of ObjC super class/protocols in interfaces and protocols.
llvm-svn: 262584
Diffstat (limited to 'clang/lib/Index/IndexDecl.cpp')
-rw-r--r-- | clang/lib/Index/IndexDecl.cpp | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/clang/lib/Index/IndexDecl.cpp b/clang/lib/Index/IndexDecl.cpp index 76f68e564c9..af438f36843 100644 --- a/clang/lib/Index/IndexDecl.cpp +++ b/clang/lib/Index/IndexDecl.cpp @@ -14,6 +14,12 @@ using namespace clang; using namespace index; +#define TRY_TO(CALL_EXPR) \ + do { \ + if (!CALL_EXPR) \ + return false; \ + } while (0) + namespace { class IndexingDeclVisitor : public ConstDeclVisitor<IndexingDeclVisitor, bool> { @@ -196,11 +202,30 @@ public: return true; } + bool handleReferencedProtocols(const ObjCProtocolList &ProtList, + const ObjCContainerDecl *ContD) { + ObjCInterfaceDecl::protocol_loc_iterator LI = ProtList.loc_begin(); + for (ObjCInterfaceDecl::protocol_iterator + I = ProtList.begin(), E = ProtList.end(); I != E; ++I, ++LI) { + SourceLocation Loc = *LI; + ObjCProtocolDecl *PD = *I; + TRY_TO(IndexCtx.handleReference(PD, Loc, ContD, ContD, + SymbolRoleSet(), + SymbolRelation{(unsigned)SymbolRole::RelationBaseOf, ContD})); + } + return true; + } + bool VisitObjCInterfaceDecl(const ObjCInterfaceDecl *D) { if (D->isThisDeclarationADefinition()) { - if (!IndexCtx.handleDecl(D)) - return false; - IndexCtx.indexDeclContext(D); + TRY_TO(IndexCtx.handleDecl(D)); + if (auto *SuperD = D->getSuperClass()) { + TRY_TO(IndexCtx.handleReference(SuperD, D->getSuperClassLoc(), D, D, + SymbolRoleSet(), + SymbolRelation{(unsigned)SymbolRole::RelationBaseOf, D})); + } + TRY_TO(handleReferencedProtocols(D->getReferencedProtocols(), D)); + TRY_TO(IndexCtx.indexDeclContext(D)); } else { return IndexCtx.handleReference(D, D->getLocation(), nullptr, nullptr, SymbolRoleSet()); @@ -210,9 +235,9 @@ public: bool VisitObjCProtocolDecl(const ObjCProtocolDecl *D) { if (D->isThisDeclarationADefinition()) { - if (!IndexCtx.handleDecl(D)) - return false; - IndexCtx.indexDeclContext(D); + TRY_TO(IndexCtx.handleDecl(D)); + TRY_TO(handleReferencedProtocols(D->getReferencedProtocols(), D)); + TRY_TO(IndexCtx.indexDeclContext(D)); } else { return IndexCtx.handleReference(D, D->getLocation(), nullptr, nullptr, SymbolRoleSet()); |