llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-tools-extra Author: Nathan Ridge (HighCommander4) <details> <summary>Changes</summary> The code was already handling template template parameters, but it used TemplateName::getAsTemplateDecl() which does not work for a template template parameter referenced inside a pack index. Fixes https://github.com/clangd/clangd/issues/2712 --- Full diff: https://github.com/llvm/llvm-project/pull/228996.diff 2 Files Affected: - (modified) clang-tools-extra/clangd/FindTarget.cpp (+1-2) - (modified) clang-tools-extra/clangd/unittests/FindTargetTests.cpp (+10) ``````````diff diff --git a/clang-tools-extra/clangd/FindTarget.cpp b/clang-tools-extra/clangd/FindTarget.cpp index a3379d1337d62..efdb24086a27f 100644 --- a/clang-tools-extra/clangd/FindTarget.cpp +++ b/clang-tools-extra/clangd/FindTarget.cpp @@ -454,8 +454,7 @@ struct TargetFinder { // specializations of template template parameters aren't instantiated // into decls, so they must refer to the parameter itself. else if (const auto *Parm = - llvm::dyn_cast_or_null<TemplateTemplateParmDecl>( - TST->getTemplateName().getAsTemplateDecl())) + TST->getTemplateName().getAsTemplateTemplateParmDecl()) Outer.add(Parm, Flags); // class template specializations have a (specialized) CXXRecordDecl. else if (const CXXRecordDecl *RD = TST->getAsCXXRecordDecl()) diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp index 94837803cd64c..8eb70597a5713 100644 --- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -626,6 +626,16 @@ TEST_F(TargetDeclTest, ClassTemplate) { )cpp"; EXPECT_DECLS("DeducedTemplateSpecializationTypeLoc", "template <typename> class ...X"); + + Code = R"cpp( + // Specialization of an indexed template template parameter pack + template <template <typename> class... X> + void foo() { + [[X]]...[0]<int> x; + } + )cpp"; + EXPECT_DECLS("TemplateSpecializationTypeLoc", + "template <typename> class ...X"); } TEST_F(TargetDeclTest, Concept) { `````````` </details> https://github.com/llvm/llvm-project/pull/228996 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
