[PATCH] D49002: [Index] Add index::IndexingOptions::IndexImplicitInstantiation
This revision was automatically updated to reflect the committed changes. Closed by commit rL336606: [Index] Add index::IndexingOptions::IndexImplicitInstantiation (authored by MaskRay, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D49002?vs=154337=154704#toc Repository: rL LLVM https://reviews.llvm.org/D49002 Files: cfe/trunk/include/clang/Index/IndexingAction.h cfe/trunk/lib/Index/IndexDecl.cpp cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp cfe/trunk/lib/Index/IndexingContext.cpp cfe/trunk/lib/Index/IndexingContext.h Index: cfe/trunk/include/clang/Index/IndexingAction.h === --- cfe/trunk/include/clang/Index/IndexingAction.h +++ cfe/trunk/include/clang/Index/IndexingAction.h @@ -39,6 +39,7 @@ SystemSymbolFilterKind SystemSymbolFilter = SystemSymbolFilterKind::DeclarationsOnly; bool IndexFunctionLocals = false; + bool IndexImplicitInstantiation = false; }; /// Creates a frontend action that indexes all symbols (macros and AST decls). Index: cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp === --- cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp +++ cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp @@ -129,7 +129,7 @@ template bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) { if (const auto *T = TL.getTypePtr()) { - if (IndexCtx.shouldIndexImplicitTemplateInsts()) { + if (IndexCtx.shouldIndexImplicitInstantiation()) { if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) IndexCtx.handleReference(RD, TL.getTemplateNameLoc(), Parent, ParentDC, SymbolRoleSet(), Relations); Index: cfe/trunk/lib/Index/IndexingContext.h === --- cfe/trunk/lib/Index/IndexingContext.h +++ cfe/trunk/lib/Index/IndexingContext.h @@ -60,9 +60,7 @@ bool shouldIndexFunctionLocalSymbols() const; - bool shouldIndexImplicitTemplateInsts() const { -return false; - } + bool shouldIndexImplicitInstantiation() const; static bool isTemplateImplicitInstantiation(const Decl *D); Index: cfe/trunk/lib/Index/IndexDecl.cpp === --- cfe/trunk/lib/Index/IndexDecl.cpp +++ cfe/trunk/lib/Index/IndexDecl.cpp @@ -726,7 +726,7 @@ if (D->isImplicit() && shouldIgnoreIfImplicit(D)) return true; - if (isTemplateImplicitInstantiation(D)) + if (isTemplateImplicitInstantiation(D) && !shouldIndexImplicitInstantiation()) return true; IndexingDeclVisitor Visitor(*this); Index: cfe/trunk/lib/Index/IndexingContext.cpp === --- cfe/trunk/lib/Index/IndexingContext.cpp +++ cfe/trunk/lib/Index/IndexingContext.cpp @@ -37,6 +37,10 @@ return IndexOpts.IndexFunctionLocals; } +bool IndexingContext::shouldIndexImplicitInstantiation() const { + return IndexOpts.IndexImplicitInstantiation; +} + bool IndexingContext::handleDecl(const Decl *D, SymbolRoleSet Roles, ArrayRef Relations) { Index: cfe/trunk/include/clang/Index/IndexingAction.h === --- cfe/trunk/include/clang/Index/IndexingAction.h +++ cfe/trunk/include/clang/Index/IndexingAction.h @@ -39,6 +39,7 @@ SystemSymbolFilterKind SystemSymbolFilter = SystemSymbolFilterKind::DeclarationsOnly; bool IndexFunctionLocals = false; + bool IndexImplicitInstantiation = false; }; /// Creates a frontend action that indexes all symbols (macros and AST decls). Index: cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp === --- cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp +++ cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp @@ -129,7 +129,7 @@ template bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) { if (const auto *T = TL.getTypePtr()) { - if (IndexCtx.shouldIndexImplicitTemplateInsts()) { + if (IndexCtx.shouldIndexImplicitInstantiation()) { if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) IndexCtx.handleReference(RD, TL.getTemplateNameLoc(), Parent, ParentDC, SymbolRoleSet(), Relations); Index: cfe/trunk/lib/Index/IndexingContext.h === --- cfe/trunk/lib/Index/IndexingContext.h +++ cfe/trunk/lib/Index/IndexingContext.h @@ -60,9 +60,7 @@ bool shouldIndexFunctionLocalSymbols() const; - bool shouldIndexImplicitTemplateInsts() const { -return false; - } + bool shouldIndexImplicitInstantiation() const; static bool isTemplateImplicitInstantiation(const Decl *D); Index: cfe/trunk/lib/Index/IndexDecl.cpp
[PATCH] D49002: [Index] Add index::IndexingOptions::IndexImplicitInstantiation
MaskRay created this revision. MaskRay added reviewers: akyrtzi, arphaman. Herald added a subscriber: cfe-commits. With IndexImplicitInstantiation=true, the following case records an occurrence of B::bar in A::foo, which will benefit cross reference tools. template struct B { void bar() {}}; template struct A { void foo(B *x) { x->bar(); }}; int main() { A a; a.foo(0); } Repository: rC Clang https://reviews.llvm.org/D49002 Files: include/clang/Index/IndexingAction.h lib/Index/IndexDecl.cpp lib/Index/IndexTypeSourceInfo.cpp lib/Index/IndexingContext.cpp lib/Index/IndexingContext.h Index: lib/Index/IndexingContext.h === --- lib/Index/IndexingContext.h +++ lib/Index/IndexingContext.h @@ -58,9 +58,7 @@ bool shouldIndexFunctionLocalSymbols() const; - bool shouldIndexImplicitTemplateInsts() const { -return false; - } + bool shouldIndexImplicitInstantiation() const; static bool isTemplateImplicitInstantiation(const Decl *D); Index: lib/Index/IndexingContext.cpp === --- lib/Index/IndexingContext.cpp +++ lib/Index/IndexingContext.cpp @@ -36,6 +36,10 @@ return IndexOpts.IndexFunctionLocals; } +bool IndexingContext::shouldIndexImplicitInstantiation() const { + return IndexOpts.IndexImplicitInstantiation; +} + bool IndexingContext::handleDecl(const Decl *D, SymbolRoleSet Roles, ArrayRef Relations) { Index: lib/Index/IndexTypeSourceInfo.cpp === --- lib/Index/IndexTypeSourceInfo.cpp +++ lib/Index/IndexTypeSourceInfo.cpp @@ -129,7 +129,7 @@ template bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) { if (const auto *T = TL.getTypePtr()) { - if (IndexCtx.shouldIndexImplicitTemplateInsts()) { + if (IndexCtx.shouldIndexImplicitInstantiation()) { if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) IndexCtx.handleReference(RD, TL.getTemplateNameLoc(), Parent, ParentDC, SymbolRoleSet(), Relations); Index: lib/Index/IndexDecl.cpp === --- lib/Index/IndexDecl.cpp +++ lib/Index/IndexDecl.cpp @@ -726,7 +726,7 @@ if (D->isImplicit() && shouldIgnoreIfImplicit(D)) return true; - if (isTemplateImplicitInstantiation(D)) + if (isTemplateImplicitInstantiation(D) && !shouldIndexImplicitInstantiation()) return true; IndexingDeclVisitor Visitor(*this); Index: include/clang/Index/IndexingAction.h === --- include/clang/Index/IndexingAction.h +++ include/clang/Index/IndexingAction.h @@ -38,6 +38,7 @@ SystemSymbolFilterKind SystemSymbolFilter = SystemSymbolFilterKind::DeclarationsOnly; bool IndexFunctionLocals = false; + bool IndexImplicitInstantiation = false; }; /// \param WrappedAction another frontend action to wrap over or null. Index: lib/Index/IndexingContext.h === --- lib/Index/IndexingContext.h +++ lib/Index/IndexingContext.h @@ -58,9 +58,7 @@ bool shouldIndexFunctionLocalSymbols() const; - bool shouldIndexImplicitTemplateInsts() const { -return false; - } + bool shouldIndexImplicitInstantiation() const; static bool isTemplateImplicitInstantiation(const Decl *D); Index: lib/Index/IndexingContext.cpp === --- lib/Index/IndexingContext.cpp +++ lib/Index/IndexingContext.cpp @@ -36,6 +36,10 @@ return IndexOpts.IndexFunctionLocals; } +bool IndexingContext::shouldIndexImplicitInstantiation() const { + return IndexOpts.IndexImplicitInstantiation; +} + bool IndexingContext::handleDecl(const Decl *D, SymbolRoleSet Roles, ArrayRef Relations) { Index: lib/Index/IndexTypeSourceInfo.cpp === --- lib/Index/IndexTypeSourceInfo.cpp +++ lib/Index/IndexTypeSourceInfo.cpp @@ -129,7 +129,7 @@ template bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) { if (const auto *T = TL.getTypePtr()) { - if (IndexCtx.shouldIndexImplicitTemplateInsts()) { + if (IndexCtx.shouldIndexImplicitInstantiation()) { if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) IndexCtx.handleReference(RD, TL.getTemplateNameLoc(), Parent, ParentDC, SymbolRoleSet(), Relations); Index: lib/Index/IndexDecl.cpp === --- lib/Index/IndexDecl.cpp +++ lib/Index/IndexDecl.cpp @@ -726,7 +726,7 @@ if (D->isImplicit() && shouldIgnoreIfImplicit(D)) return true; - if (isTemplateImplicitInstantiation(D)) + if