[PATCH] D49002: [Index] Add index::IndexingOptions::IndexImplicitInstantiation
Fangrui Song via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 5 17:02:16 PDT 2018
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 <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); }
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<SymbolRelation> Relations) {
Index: lib/Index/IndexTypeSourceInfo.cpp
===================================================================
--- lib/Index/IndexTypeSourceInfo.cpp
+++ lib/Index/IndexTypeSourceInfo.cpp
@@ -129,7 +129,7 @@
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);
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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49002.154337.patch
Type: text/x-patch
Size: 2527 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180706/6fb021a7/attachment.bin>
More information about the cfe-commits
mailing list