Index: lib/Index/IndexDecl.cpp =================================================================== --- lib/Index/IndexDecl.cpp +++ lib/Index/IndexDecl.cpp @@ -611,18 +611,16 @@ ClassTemplateSpecializationDecl *D) { // FIXME: Notify subsequent callbacks if info comes from implicit // instantiation. - if (D->isThisDeclarationADefinition()) { - llvm::PointerUnion - Template = D->getSpecializedTemplateOrPartial(); - const Decl *SpecializationOf = - Template.is() - ? (Decl *)Template.get() - : Template.get(); - IndexCtx.indexTagDecl( - D, SymbolRelation(SymbolRoleSet(SymbolRole::RelationSpecializationOf), - SpecializationOf)); - } + llvm::PointerUnion + Template = D->getSpecializedTemplateOrPartial(); + const Decl *SpecializationOf = + Template.is() + ? (Decl *)Template.get() + : Template.get(); + IndexCtx.indexTagDecl( + D, SymbolRelation(SymbolRoleSet(SymbolRole::RelationSpecializationOf), + SpecializationOf)); if (TypeSourceInfo *TSI = D->getTypeAsWritten()) IndexCtx.indexTypeSourceInfo(TSI, /*Parent=*/nullptr, D->getLexicalDeclContext()); Index: test/Index/Core/index-source.cpp =================================================================== --- test/Index/Core/index-source.cpp +++ test/Index/Core/index-source.cpp @@ -282,7 +282,9 @@ template<> class SpecializationDecl; -// CHECK: [[@LINE-1]]:7 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl | | Ref | rel: 0 +// CHECK: [[@LINE-1]]:7 | class(Gen,TS)/C++ | SpecializationDecl | c:@S@SpecializationDecl>#I | | Decl,RelSpecialization | rel: 1 +// CHECK-NEXT: RelSpecialization | SpecializationDecl | c:@ST>1#T@SpecializationDecl +// CHECK: [[@LINE-3]]:7 | class(Gen)/C++ | SpecializationDecl | c:@ST>1#T@SpecializationDecl | | Ref | rel: 0 template<> class SpecializationDecl { }; @@ -292,8 +294,10 @@ template class PartialSpecilizationClass; -// CHECK: [[@LINE-1]]:7 | class(Gen)/C++ | PartialSpecilizationClass | c:@ST>2#T#T@PartialSpecilizationClass | | Ref | rel: 0 -// CHECK-NEXT: [[@LINE-2]]:33 | class/C++ | Cls | c:@S@Cls | | Ref | rel: 0 +// CHECK: [[@LINE-1]]:7 | class(Gen,TPS)/C++ | PartialSpecilizationClass | c:@SP>1#T@PartialSpecilizationClass>#$@S@Cls#t0.0 | | Decl,RelSpecialization | rel: 1 +// CHECK-NEXT: RelSpecialization | PartialSpecilizationClass | c:@ST>2#T#T@PartialSpecilizationClass +// CHECK: [[@LINE-3]]:7 | class(Gen)/C++ | PartialSpecilizationClass | c:@ST>2#T#T@PartialSpecilizationClass | | Ref | rel: 0 +// CHECK-NEXT: [[@LINE-4]]:33 | class/C++ | Cls | c:@S@Cls | | Ref | rel: 0 template<> class PartialSpecilizationClass : Cls { };