Author: ioeric Date: Fri Jul 20 01:08:56 2018 New Revision: 337529 URL: http://llvm.org/viewvc/llvm-project?rev=337529&view=rev Log: [Index] Set OrigD before D is changed.
Reviewers: akyrtzi, arphaman Reviewed By: akyrtzi Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D49476 Added: cfe/trunk/test/Index/index-template-specialization.cpp Modified: cfe/trunk/lib/Index/IndexingContext.cpp cfe/trunk/tools/c-index-test/c-index-test.c cfe/trunk/tools/libclang/Indexing.cpp Modified: cfe/trunk/lib/Index/IndexingContext.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexingContext.cpp?rev=337529&r1=337528&r2=337529&view=diff ============================================================================== --- cfe/trunk/lib/Index/IndexingContext.cpp (original) +++ cfe/trunk/lib/Index/IndexingContext.cpp Fri Jul 20 01:08:56 2018 @@ -350,6 +350,9 @@ bool IndexingContext::handleDeclOccurren } } + if (!OrigD) + OrigD = D; + if (isTemplateImplicitInstantiation(D)) { if (!IsRef) return true; @@ -359,9 +362,6 @@ bool IndexingContext::handleDeclOccurren assert(!isTemplateImplicitInstantiation(D)); } - if (!OrigD) - OrigD = D; - if (IsRef) Roles |= (unsigned)SymbolRole::Reference; else if (isDeclADefinition(OrigD, ContainerDC, *Ctx)) Added: cfe/trunk/test/Index/index-template-specialization.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-template-specialization.cpp?rev=337529&view=auto ============================================================================== --- cfe/trunk/test/Index/index-template-specialization.cpp (added) +++ cfe/trunk/test/Index/index-template-specialization.cpp Fri Jul 20 01:08:56 2018 @@ -0,0 +1,19 @@ +template <typename T> +class Foo { +public: + void f(T t) {} +}; + +void g() { + Foo<int> foo; + foo.f(0); +} + +// FIXME: if c-index-test uses OrigD for symbol info, refererences below should +// refer to template specialization decls. +// RUN: env CINDEXTEST_INDEXIMPLICITTEMPLATEINSTANTIATIONS=1 c-index-test -index-file %s | FileCheck %s +// CHECK: [indexDeclaration]: kind: c++-class-template | name: Foo +// CHECK-NEXT: [indexDeclaration]: kind: c++-instance-method | name: f +// CHECK-NEXT: [indexDeclaration]: kind: function | name: g +// CHECK-NEXT: [indexEntityReference]: kind: c++-class-template | name: Foo | USR: c:@ST>1#T@Foo +// CHECK-NEXT: [indexEntityReference]: kind: c++-instance-method | name: f | USR: c:@ST>1#T@Foo@F@f#t0.0# Modified: cfe/trunk/tools/c-index-test/c-index-test.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=337529&r1=337528&r2=337529&view=diff ============================================================================== --- cfe/trunk/tools/c-index-test/c-index-test.c (original) +++ cfe/trunk/tools/c-index-test/c-index-test.c Fri Jul 20 01:08:56 2018 @@ -3652,6 +3652,8 @@ static unsigned getIndexOptions(void) { index_opts |= CXIndexOpt_IndexFunctionLocalSymbols; if (!getenv("CINDEXTEST_DISABLE_SKIPPARSEDBODIES")) index_opts |= CXIndexOpt_SkipParsedBodiesInSession; + if (getenv("CINDEXTEST_INDEXIMPLICITTEMPLATEINSTANTIATIONS")) + index_opts |= CXIndexOpt_IndexImplicitTemplateInstantiations; return index_opts; } Modified: cfe/trunk/tools/libclang/Indexing.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/Indexing.cpp?rev=337529&r1=337528&r2=337529&view=diff ============================================================================== --- cfe/trunk/tools/libclang/Indexing.cpp (original) +++ cfe/trunk/tools/libclang/Indexing.cpp Fri Jul 20 01:08:56 2018 @@ -402,6 +402,8 @@ static IndexingOptions getIndexingOption IndexingOptions IdxOpts; if (index_options & CXIndexOpt_IndexFunctionLocalSymbols) IdxOpts.IndexFunctionLocals = true; + if (index_options & CXIndexOpt_IndexImplicitTemplateInstantiations) + IdxOpts.IndexImplicitInstantiation = true; return IdxOpts; } _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits