[PATCH] D68120: [clangd] Handle type template parameters in findExplicitReferences
Ilya Biryukov via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 27 04:00:06 PDT 2019
ilya-biryukov updated this revision to Diff 222126.
ilya-biryukov added a comment.
- Add tests for non-type template paremeters
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68120/new/
https://reviews.llvm.org/D68120
Files:
clang-tools-extra/clangd/FindTarget.cpp
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/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/clangd/FindTarget.cpp
===================================================================
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/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.222126.patch
Type: text/x-patch
Size: 1631 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190927/d15647b4/attachment-0001.bin>
More information about the cfe-commits
mailing list