[PATCH] D153251: [clangd] Index the type of a non-type template parameter
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 19 00:53:51 PDT 2023
nridge created this revision.
nridge added a reviewer: hokein.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
nridge requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added projects: clang, clang-tools-extra.
Fixes https://github.com/clangd/clangd/issues/1666
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D153251
Files:
clang-tools-extra/clangd/unittests/XRefsTests.cpp
clang/lib/Index/IndexDecl.cpp
Index: clang/lib/Index/IndexDecl.cpp
===================================================================
--- clang/lib/Index/IndexDecl.cpp
+++ clang/lib/Index/IndexDecl.cpp
@@ -705,6 +705,7 @@
IndexCtx.handleReference(C->getNamedConcept(), C->getConceptNameLoc(),
Parent, TTP->getLexicalDeclContext());
} else if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(TP)) {
+ IndexCtx.indexTypeSourceInfo(NTTP->getTypeSourceInfo(), Parent);
if (NTTP->hasDefaultArgument())
IndexCtx.indexBody(NTTP->getDefaultArgument(), Parent);
} else if (const auto *TTPD = dyn_cast<TemplateTemplateParmDecl>(TP)) {
Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -2125,7 +2125,13 @@
using $def[[MyTypeD^ef]] = int;
enum MyEnum : $(MyEnum)[[MyTy^peDef]] { };
)cpp",
- };
+
+ // Template parameter
+ R"cpp(
+ enum class $def[[Foo^bar]] { foo };
+ template <$(func)[[Foobar]] f>
+ constexpr void func() {}
+ )cpp"};
for (const char *Test : Tests)
checkFindRefs(Test);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153251.532555.patch
Type: text/x-patch
Size: 1300 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230619/4e1957df/attachment-0001.bin>
More information about the cfe-commits
mailing list