[clang][index] Index the injected class name types.
Summary: Currently, we (clangd) are missing this kind of references.
Reviewers: kadircet
Subscribers: ilya-biryukov, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73109
diff --git a/clang/unittests/Index/IndexTests.cpp b/clang/unittests/Index/IndexTests.cpp
index 000cfe2..3ccec683 100644
--- a/clang/unittests/Index/IndexTests.cpp
+++ b/clang/unittests/Index/IndexTests.cpp
@@ -293,6 +293,27 @@
WrittenAt(Position(4, 8)))));
}
+TEST(IndexTest, InjecatedNameClass) {
+ std::string Code = R"cpp(
+ template <typename T>
+ class Foo {
+ void f(Foo x);
+ };
+ )cpp";
+ auto Index = std::make_shared<Indexer>();
+ IndexingOptions Opts;
+ tooling::runToolOnCode(std::make_unique<IndexAction>(Index, Opts), Code);
+ EXPECT_THAT(Index->Symbols,
+ UnorderedElementsAre(AllOf(QName("Foo"), Kind(SymbolKind::Class),
+ WrittenAt(Position(3, 11))),
+ AllOf(QName("Foo::f"),
+ Kind(SymbolKind::InstanceMethod),
+ WrittenAt(Position(4, 12))),
+ AllOf(QName("Foo"), Kind(SymbolKind::Class),
+ HasRole(SymbolRole::Reference),
+ WrittenAt(Position(4, 14)))));
+}
+
} // namespace
} // namespace index
} // namespace clang