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)) {


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)) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to