[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:24:38 PDT 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf4ba7a100a56: [clangd] Semantic highlighting for dependent template name in template argument (authored by nridge).
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.283787.patch
Type: text/x-patch
Size: 1688 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200807/b38009fb/attachment.bin>
More information about the cfe-commits
mailing list