Author: ibiryukov Date: Fri Sep 27 03:55:53 2019 New Revision: 373067 URL: http://llvm.org/viewvc/llvm-project?rev=373067&view=rev Log: [clangd] Handle type template parameters in findExplicitReferences
Reviewers: kadircet Reviewed By: kadircet Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68120 Modified: clang-tools-extra/trunk/clangd/FindTarget.cpp clang-tools-extra/trunk/clangd/unittests/FindTargetTests.cpp Modified: clang-tools-extra/trunk/clangd/FindTarget.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FindTarget.cpp?rev=373067&r1=373066&r2=373067&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/FindTarget.cpp (original) +++ clang-tools-extra/trunk/clangd/FindTarget.cpp Fri Sep 27 03:55:53 2019 @@ -489,6 +489,11 @@ Optional<ReferenceLoc> refInTypeLoc(Type ReferenceLoc{NestedNameSpecifierLoc(), L.getNameLoc(), {L.getDecl()}}; } + void VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc L) { + Ref = + ReferenceLoc{NestedNameSpecifierLoc(), L.getNameLoc(), {L.getDecl()}}; + } + void VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc L) { Ref = ReferenceLoc{ NestedNameSpecifierLoc(), L.getTemplateNameLoc(), Modified: clang-tools-extra/trunk/clangd/unittests/FindTargetTests.cpp URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/FindTargetTests.cpp?rev=373067&r1=373066&r2=373067&view=diff ============================================================================== --- clang-tools-extra/trunk/clangd/unittests/FindTargetTests.cpp (original) +++ clang-tools-extra/trunk/clangd/unittests/FindTargetTests.cpp Fri Sep 27 03:55:53 2019 @@ -706,6 +706,26 @@ TEST_F(FindExplicitReferencesTest, All) "0: targets = {x}\n" "1: targets = {X::func, X::func}\n" "2: targets = {t}\n"}, + // Type template parameters. + {R"cpp( + template <class T> + void foo() { + static_cast<$0^T>(0); + $1^T(); + $2^T t; + } + )cpp", + "0: targets = {T}\n" + "1: targets = {T}\n" + "2: targets = {T}\n"}, + // Non-type template parameters. + {R"cpp( + template <int I> + void foo() { + int x = $0^I; + } + )cpp", + "0: targets = {I}\n"}, }; for (const auto &C : Cases) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits