[PATCH] D36641: [index] Update indexing to handle CXXDeductionGuideDecls properly
This revision was automatically updated to reflect the committed changes. Closed by commit rL310933: [index] Update indexing to handle CXXDeductionGuideDecls properly (authored by akirtzidis). Changed prior to commit: https://reviews.llvm.org/D36641?vs=110829=99#toc Repository: rL LLVM https://reviews.llvm.org/D36641 Files: cfe/trunk/lib/Index/IndexDecl.cpp cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp cfe/trunk/lib/Index/IndexingContext.cpp cfe/trunk/test/Index/Core/index-source.cpp Index: cfe/trunk/test/Index/Core/index-source.cpp === --- cfe/trunk/test/Index/Core/index-source.cpp +++ cfe/trunk/test/Index/Core/index-source.cpp @@ -497,6 +497,19 @@ } +template +struct Guided { T t; }; +// CHECK: [[@LINE-1]]:8 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | | Def | rel: 0 +// CHECK-NEXT: [[@LINE-2]]:19 | field/C++ | t | c:@ST>1#T@Guided@FI@t | | Def,RelChild | rel: 1 +// CHECK-NEXT: RelChild | Guided | c:@ST>1#T@Guided +Guided(double) -> Guided; +// CHECK: [[@LINE-1]]:19 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | | Ref | rel: 0 +// CHECK-NEXT: [[@LINE-2]]:1 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | | Ref | rel: 0 +auto guided = Guided{1.0}; +// CHECK: [[@LINE-1]]:6 | variable/C | guided | c:@guided | _guided | Def | rel: 0 +// CHECK-NEXT: [[@LINE-2]]:15 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont | guided | c:@guided + namespace rd33122110 { struct Outer { Index: cfe/trunk/lib/Index/IndexingContext.cpp === --- cfe/trunk/lib/Index/IndexingContext.cpp +++ cfe/trunk/lib/Index/IndexingContext.cpp @@ -231,8 +231,8 @@ /// Whether the given NamedDecl should be skipped because it has no name. static bool shouldSkipNamelessDecl(const NamedDecl *ND) { - return ND->getDeclName().isEmpty() && !isa(ND) && - !isa(ND); + return (ND->getDeclName().isEmpty() && !isa(ND) && + !isa(ND)) || isa(ND); } static const Decl *adjustParent(const Decl *Parent) { Index: cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp === --- cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp +++ cfe/trunk/lib/Index/IndexTypeSourceInfo.cpp @@ -126,8 +126,9 @@ return true; } - bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) { -if (const TemplateSpecializationType *T = TL.getTypePtr()) { + template + bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) { +if (const auto *T = TL.getTypePtr()) { if (IndexCtx.shouldIndexImplicitTemplateInsts()) { if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) IndexCtx.handleReference(RD, TL.getTemplateNameLoc(), @@ -141,6 +142,14 @@ return true; } + bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) { +return HandleTemplateSpecializationTypeLoc(TL); + } + + bool VisitDeducedTemplateSpecializationTypeLoc(DeducedTemplateSpecializationTypeLoc TL) { +return HandleTemplateSpecializationTypeLoc(TL); + } + bool VisitDependentNameTypeLoc(DependentNameTypeLoc TL) { const DependentNameType *DNT = TL.getTypePtr(); const NestedNameSpecifier *NNS = DNT->getQualifier(); Index: cfe/trunk/lib/Index/IndexDecl.cpp === --- cfe/trunk/lib/Index/IndexDecl.cpp +++ cfe/trunk/lib/Index/IndexDecl.cpp @@ -267,6 +267,10 @@ TypeNameInfo->getTypeLoc().getLocStart(), Dtor->getParent(), Dtor->getDeclContext()); } +} else if (const auto *Guide = dyn_cast(D)) { + IndexCtx.handleReference(Guide->getDeducedTemplate()->getTemplatedDecl(), + Guide->getLocation(), Guide, + Guide->getDeclContext()); } // Template specialization arguments. if (const ASTTemplateArgumentListInfo *TemplateArgInfo = Index: cfe/trunk/test/Index/Core/index-source.cpp === --- cfe/trunk/test/Index/Core/index-source.cpp +++ cfe/trunk/test/Index/Core/index-source.cpp @@ -497,6 +497,19 @@ } +template +struct Guided { T t; }; +// CHECK: [[@LINE-1]]:8 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | | Def | rel: 0 +// CHECK-NEXT: [[@LINE-2]]:19 | field/C++ | t | c:@ST>1#T@Guided@FI@t | | Def,RelChild | rel: 1 +// CHECK-NEXT: RelChild | Guided | c:@ST>1#T@Guided +Guided(double) -> Guided; +// CHECK: [[@LINE-1]]:19 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | | Ref | rel: 0 +// CHECK-NEXT: [[@LINE-2]]:1 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | | Ref | rel: 0 +auto guided = Guided{1.0}; +// CHECK: [[@LINE-1]]:6 | variable/C | guided | c:@guided | _guided | Def | rel: 0 +// CHECK-NEXT: [[@LINE-2]]:15 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | |
[PATCH] D36641: [index] Update indexing to handle CXXDeductionGuideDecls properly
nathawes created this revision. CXXDeductionGuideDecls can't be referenced so there's no need to output a symbol occurrence for them. Also handle DeducedTemplateSpecializationTypeLocs in the TypeIndexer so we don't miss the symbol occurrences of the corresponding template decls. https://reviews.llvm.org/D36641 Files: lib/Index/IndexDecl.cpp lib/Index/IndexTypeSourceInfo.cpp lib/Index/IndexingContext.cpp test/Index/Core/index-source.cpp Index: test/Index/Core/index-source.cpp === --- test/Index/Core/index-source.cpp +++ test/Index/Core/index-source.cpp @@ -497,6 +497,19 @@ } +template +struct Guided { T t; }; +// CHECK: [[@LINE-1]]:8 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | | Def | rel: 0 +// CHECK-NEXT: [[@LINE-2]]:19 | field/C++ | t | c:@ST>1#T@Guided@FI@t | | Def,RelChild | rel: 1 +// CHECK-NEXT: RelChild | Guided | c:@ST>1#T@Guided +Guided(double) -> Guided; +// CHECK: [[@LINE-1]]:19 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | | Ref | rel: 0 +// CHECK-NEXT: [[@LINE-2]]:1 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | | Ref | rel: 0 +auto guided = Guided{1.0}; +// CHECK: [[@LINE-1]]:6 | variable/C | guided | c:@guided | _guided | Def | rel: 0 +// CHECK-NEXT: [[@LINE-2]]:15 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont | guided | c:@guided + namespace rd33122110 { struct Outer { Index: lib/Index/IndexingContext.cpp === --- lib/Index/IndexingContext.cpp +++ lib/Index/IndexingContext.cpp @@ -231,8 +231,8 @@ /// Whether the given NamedDecl should be skipped because it has no name. static bool shouldSkipNamelessDecl(const NamedDecl *ND) { - return ND->getDeclName().isEmpty() && !isa(ND) && - !isa(ND); + return (ND->getDeclName().isEmpty() && !isa(ND) && + !isa(ND)) || isa(ND); } static const Decl *adjustParent(const Decl *Parent) { Index: lib/Index/IndexTypeSourceInfo.cpp === --- lib/Index/IndexTypeSourceInfo.cpp +++ lib/Index/IndexTypeSourceInfo.cpp @@ -126,8 +126,9 @@ return true; } - bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) { -if (const TemplateSpecializationType *T = TL.getTypePtr()) { + template + bool HandleTemplateSpecializationTypeLoc(TypeLocType TL) { +if (const auto *T = TL.getTypePtr()) { if (IndexCtx.shouldIndexImplicitTemplateInsts()) { if (CXXRecordDecl *RD = T->getAsCXXRecordDecl()) IndexCtx.handleReference(RD, TL.getTemplateNameLoc(), @@ -141,6 +142,14 @@ return true; } + bool VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc TL) { +return HandleTemplateSpecializationTypeLoc(TL); + } + + bool VisitDeducedTemplateSpecializationTypeLoc(DeducedTemplateSpecializationTypeLoc TL) { +return HandleTemplateSpecializationTypeLoc(TL); + } + bool VisitDependentNameTypeLoc(DependentNameTypeLoc TL) { const DependentNameType *DNT = TL.getTypePtr(); const NestedNameSpecifier *NNS = DNT->getQualifier(); Index: lib/Index/IndexDecl.cpp === --- lib/Index/IndexDecl.cpp +++ lib/Index/IndexDecl.cpp @@ -267,6 +267,10 @@ TypeNameInfo->getTypeLoc().getLocStart(), Dtor->getParent(), Dtor->getDeclContext()); } +} else if (const auto *Guide = dyn_cast(D)) { + IndexCtx.handleReference(Guide->getDeducedTemplate()->getTemplatedDecl(), + Guide->getLocation(), Guide, + Guide->getDeclContext()); } // Template specialization arguments. if (const ASTTemplateArgumentListInfo *TemplateArgInfo = Index: test/Index/Core/index-source.cpp === --- test/Index/Core/index-source.cpp +++ test/Index/Core/index-source.cpp @@ -497,6 +497,19 @@ } +template +struct Guided { T t; }; +// CHECK: [[@LINE-1]]:8 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | | Def | rel: 0 +// CHECK-NEXT: [[@LINE-2]]:19 | field/C++ | t | c:@ST>1#T@Guided@FI@t | | Def,RelChild | rel: 1 +// CHECK-NEXT: RelChild | Guided | c:@ST>1#T@Guided +Guided(double) -> Guided; +// CHECK: [[@LINE-1]]:19 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | | Ref | rel: 0 +// CHECK-NEXT: [[@LINE-2]]:1 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | | Ref | rel: 0 +auto guided = Guided{1.0}; +// CHECK: [[@LINE-1]]:6 | variable/C | guided | c:@guided | _guided | Def | rel: 0 +// CHECK-NEXT: [[@LINE-2]]:15 | struct(Gen)/C++ | Guided | c:@ST>1#T@Guided | | Ref,RelCont | rel: 1 +// CHECK-NEXT: RelCont | guided | c:@guided + namespace rd33122110 { struct Outer { Index: lib/Index/IndexingContext.cpp