[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
Tue Jun 20 00:23:06 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc3075023850b: [clangd] Index the type of a non-type template parameter (authored by nridge).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153251/new/
https://reviews.llvm.org/D153251
Files:
clang/lib/Index/IndexDecl.cpp
clang/unittests/Index/IndexTests.cpp
Index: clang/unittests/Index/IndexTests.cpp
===================================================================
--- clang/unittests/Index/IndexTests.cpp
+++ clang/unittests/Index/IndexTests.cpp
@@ -392,6 +392,20 @@
Contains(AllOf(QName("MyTypedef"), HasRole(SymbolRole::Reference),
WrittenAt(Position(4, 16))))));
}
+
+TEST(IndexTest, NonTypeTemplateParameter) {
+ std::string Code = R"cpp(
+ enum class Foobar { foo };
+ template <Foobar f>
+ constexpr void func() {}
+ )cpp";
+ auto Index = std::make_shared<Indexer>();
+ tooling::runToolOnCode(std::make_unique<IndexAction>(Index), Code);
+ EXPECT_THAT(Index->Symbols,
+ Contains(AllOf(QName("Foobar"), HasRole(SymbolRole::Reference),
+ WrittenAt(Position(3, 15)))));
+}
+
} // namespace
} // namespace index
} // namespace clang
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)) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153251.532807.patch
Type: text/x-patch
Size: 1572 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230620/a81859dd/attachment.bin>
More information about the cfe-commits
mailing list