[PATCH] D85272: [clangd] Semantic highlighting for dependent template name in template argument
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 6 18:22:13 PDT 2020
nridge updated this revision to Diff 283784.
nridge added a comment.
Address nit
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D85272/new/
https://reviews.llvm.org/D85272
Files:
clang-tools-extra/clangd/SemanticHighlighting.cpp
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -686,6 +686,14 @@
void $Function[[bar]]($TemplateParameter[[T]] $Parameter[[F]]) {
$Parameter[[F]].$DependentName[[foo]]();
}
+ )cpp",
+ // Dependent template name
+ R"cpp(
+ template <template <typename> class> struct $Class[[A]] {};
+ template <typename $TemplateParameter[[T]]>
+ using $Typedef[[W]] = $Class[[A]]<
+ $TemplateParameter[[T]]::template $DependentType[[Waldo]]
+ >;
)cpp"};
for (const auto &TestCase : TestCases) {
checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -296,6 +296,18 @@
return true;
}
+ bool TraverseTemplateArgumentLoc(TemplateArgumentLoc L) {
+ switch (L.getArgument().getKind()) {
+ case TemplateArgument::Template:
+ case TemplateArgument::TemplateExpansion:
+ H.addToken(L.getTemplateNameLoc(), HighlightingKind::DependentType);
+ break;
+ default:
+ break;
+ }
+ return RecursiveASTVisitor::TraverseTemplateArgumentLoc(L);
+ }
+
// findExplicitReferences will walk nested-name-specifiers and
// find anything that can be resolved to a Decl. However, non-leaf
// components of nested-name-specifiers which are dependent names
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D85272.283784.patch
Type: text/x-patch
Size: 1688 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200807/0794a882/attachment.bin>
More information about the cfe-commits
mailing list