This revision was automatically updated to reflect the committed changes. Closed by commit rGfba563e92b64: [clangd] TargetFinder: Fix assert-crash on TemplateExpansion args. (authored by adamcz).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D111648/new/ https://reviews.llvm.org/D111648 Files: clang-tools-extra/clangd/FindTarget.cpp clang-tools-extra/clangd/unittests/FindTargetTests.cpp Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -341,6 +341,15 @@ EXPECT_DECLS("TemplateSpecializationTypeLoc", "template <typename> class T"); Flags.clear(); + Code = R"cpp( + template<template<typename> class ...T> + class C { + C<[[T...]]> foo; + }; + )cpp"; + EXPECT_DECLS("TemplateArgumentLoc", {"template <typename> class ...T"}); + Flags.clear(); + Code = R"cpp( struct S{}; S X; Index: clang-tools-extra/clangd/FindTarget.cpp =================================================================== --- clang-tools-extra/clangd/FindTarget.cpp +++ clang-tools-extra/clangd/FindTarget.cpp @@ -507,7 +507,8 @@ // DeclRefExpr). if (Arg.getKind() == TemplateArgument::Template || Arg.getKind() == TemplateArgument::TemplateExpansion) { - if (TemplateDecl *TD = Arg.getAsTemplate().getAsTemplateDecl()) { + if (TemplateDecl *TD = + Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl()) { report(TD, Flags); } }
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/FindTargetTests.cpp +++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp @@ -341,6 +341,15 @@ EXPECT_DECLS("TemplateSpecializationTypeLoc", "template <typename> class T"); Flags.clear(); + Code = R"cpp( + template<template<typename> class ...T> + class C { + C<[[T...]]> foo; + }; + )cpp"; + EXPECT_DECLS("TemplateArgumentLoc", {"template <typename> class ...T"}); + Flags.clear(); + Code = R"cpp( struct S{}; S X; Index: clang-tools-extra/clangd/FindTarget.cpp =================================================================== --- clang-tools-extra/clangd/FindTarget.cpp +++ clang-tools-extra/clangd/FindTarget.cpp @@ -507,7 +507,8 @@ // DeclRefExpr). if (Arg.getKind() == TemplateArgument::Template || Arg.getKind() == TemplateArgument::TemplateExpansion) { - if (TemplateDecl *TD = Arg.getAsTemplate().getAsTemplateDecl()) { + if (TemplateDecl *TD = + Arg.getAsTemplateOrTemplatePattern().getAsTemplateDecl()) { report(TD, Flags); } }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits