[PATCH] D111648: [clangd] TargetFinder: Fix assert-crash on TemplateExpansion args.
Adam Czachorowski via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 13 03:54:17 PDT 2021
adamcz updated this revision to Diff 379335.
adamcz marked an inline comment as done.
adamcz added a comment.
removed unnecessary Flags.clear()
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);
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D111648.379335.patch
Type: text/x-patch
Size: 1211 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211013/1aae37a6/attachment.bin>
More information about the cfe-commits
mailing list