[PATCH] D68120: [clangd] Handle type template parameters in findExplicitReferences

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Sep 27 04:00:24 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL373067: [clangd] Handle type template parameters in findExplicitReferences (authored by ibiryukov, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D68120?vs=222126&id=222127#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D68120/new/

https://reviews.llvm.org/D68120

Files:
  clang-tools-extra/trunk/clangd/FindTarget.cpp
  clang-tools-extra/trunk/clangd/unittests/FindTargetTests.cpp


Index: clang-tools-extra/trunk/clangd/unittests/FindTargetTests.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/trunk/clangd/unittests/FindTargetTests.cpp
@@ -706,6 +706,26 @@
            "0: targets = {x}\n"
            "1: targets = {X::func, X::func}\n"
            "2: targets = {t}\n"},
+          // Type template parameters.
+          {R"cpp(
+            template <class T>
+            void foo() {
+              static_cast<$0^T>(0);
+              $1^T();
+              $2^T t;
+            }
+        )cpp",
+           "0: targets = {T}\n"
+           "1: targets = {T}\n"
+           "2: targets = {T}\n"},
+          // Non-type template parameters.
+          {R"cpp(
+            template <int I>
+            void foo() {
+              int x = $0^I;
+            }
+        )cpp",
+           "0: targets = {I}\n"},
       };
 
   for (const auto &C : Cases) {
Index: clang-tools-extra/trunk/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/trunk/clangd/FindTarget.cpp
+++ clang-tools-extra/trunk/clangd/FindTarget.cpp
@@ -489,6 +489,11 @@
           ReferenceLoc{NestedNameSpecifierLoc(), L.getNameLoc(), {L.getDecl()}};
     }
 
+    void VisitTemplateTypeParmTypeLoc(TemplateTypeParmTypeLoc L) {
+      Ref =
+          ReferenceLoc{NestedNameSpecifierLoc(), L.getNameLoc(), {L.getDecl()}};
+    }
+
     void VisitTemplateSpecializationTypeLoc(TemplateSpecializationTypeLoc L) {
       Ref = ReferenceLoc{
           NestedNameSpecifierLoc(), L.getTemplateNameLoc(),


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68120.222127.patch
Type: text/x-patch
Size: 1667 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190927/825d5822/attachment.bin>


More information about the cfe-commits mailing list