diff options
author | Fangrui Song <maskray@google.com> | 2018-07-09 21:49:06 +0000 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2018-07-09 21:49:06 +0000 |
commit | d50f36ed7731de6f7238c2f5f69b5769e311bb41 (patch) | |
tree | 6504eea14478ea65964f997d763c74b284c750ec | |
parent | 4fee1356edad7075195ad11810adf25f2bcb1f27 (diff) | |
download | bcm5719-llvm-d50f36ed7731de6f7238c2f5f69b5769e311bb41.tar.gz bcm5719-llvm-d50f36ed7731de6f7238c2f5f69b5769e311bb41.zip |
[Index] Add index::IndexingOptions::IndexImplicitInstantiation
Summary:
With IndexImplicitInstantiation=true, the following case records an occurrence of B::bar in A::foo, which will benefit cross reference tools.
template <class T> struct B { void bar() {}};
template <class T> struct A { void foo(B<T> *x) { x->bar(); }};
int main() { A<int> a; a.foo(0); }
Reviewers: akyrtzi, arphaman, rsmith
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D49002
llvm-svn: 336606
-rw-r--r-- | clang/include/clang/Index/IndexingAction.h | 1 | ||||
-rw-r--r-- | clang/lib/Index/IndexDecl.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Index/IndexTypeSourceInfo.cpp | 2 | ||||
-rw-r--r-- | clang/lib/Index/IndexingContext.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Index/IndexingContext.h | 4 |
5 files changed, 8 insertions, 5 deletions
diff --git a/clang/include/clang/Index/IndexingAction.h b/clang/include/clang/Index/IndexingAction.h index 48385b396f7..64496a21ec5 100644 --- a/clang/include/clang/Index/IndexingAction.h +++ b/clang/include/clang/Index/IndexingAction.h @@ -39,6 +39,7 @@ struct IndexingOptions { SystemSymbolFilterKind SystemSymbolFilter = SystemSymbolFilterKind::DeclarationsOnly; bool IndexFunctionLocals = false; + bool IndexImplicitInstantiation = false; }; /// Creates a frontend action that indexes all symbols (macros and AST decls). diff --git a/clang/lib/Index/IndexDecl.cpp b/clang/lib/Index/IndexDecl.cpp index 01608d2b77f..01ad3a27721 100644 --- a/clang/lib/Index/IndexDecl.cpp +++ b/clang/lib/Index/IndexDecl.cpp @@ -726,7 +726,7 @@ bool IndexingContext::indexDecl(const Decl *D) { if (D->isImplicit() && shouldIgnoreIfImplicit(D)) return true; - if (isTemplateImplicitInstantiation(D)) + if (isTemplateImplicitInstantiation(D) && !shouldIndexImplicitInstantiation()) return true; IndexingDeclVisitor Visitor(*this); diff --git a/clang/lib/Index/IndexTypeSourceInfo.cpp b/clang/lib/Index/IndexTypeSourceInfo.cpp index c8ff3d72d4b..7a7a156478f 100644 --- a/clang/lib/Index/IndexTypeSourceInfo.cpp +++ b/clang/lib/Index/IndexTypeSourceInfo.cpp @@ -129,7 +129,7 @@ public: template<typename TypeLocType> 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); diff --git a/clang/lib/Index/IndexingContext.cpp b/clang/lib/Index/IndexingContext.cpp index 71b92bc6bf2..6c09ac7c09a 100644 --- a/clang/lib/Index/IndexingContext.cpp +++ b/clang/lib/Index/IndexingContext.cpp @@ -37,6 +37,10 @@ bool IndexingContext::shouldIndexFunctionLocalSymbols() const { return IndexOpts.IndexFunctionLocals; } +bool IndexingContext::shouldIndexImplicitInstantiation() const { + return IndexOpts.IndexImplicitInstantiation; +} + bool IndexingContext::handleDecl(const Decl *D, SymbolRoleSet Roles, ArrayRef<SymbolRelation> Relations) { diff --git a/clang/lib/Index/IndexingContext.h b/clang/lib/Index/IndexingContext.h index f05eaae6965..04960086d09 100644 --- a/clang/lib/Index/IndexingContext.h +++ b/clang/lib/Index/IndexingContext.h @@ -60,9 +60,7 @@ public: bool shouldIndexFunctionLocalSymbols() const; - bool shouldIndexImplicitTemplateInsts() const { - return false; - } + bool shouldIndexImplicitInstantiation() const; static bool isTemplateImplicitInstantiation(const Decl *D); |