Skip to content

Commit

Permalink
[clangd] Semantic highlighting for dependent template name in templat…
Browse files Browse the repository at this point in the history
…e argument

Fixes clangd/clangd#484

Differential Revision: https://reviews.llvm.org/D85272
  • Loading branch information
HighCommander4 committed Aug 7, 2020
1 parent ecbf2b3 commit f4ba7a1
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions clang-tools-extra/clangd/SemanticHighlighting.cpp
Expand Up @@ -296,6 +296,18 @@ class CollectExtraHighlightings
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
Expand Down
Expand Up @@ -686,6 +686,14 @@ sizeof...($TemplateParameter[[Elements]]);
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);
Expand Down

0 comments on commit f4ba7a1

Please sign in to comment.