[PATCH] D134827: [clangd] Avoid recursion on UnresolvedUsingValueDecl during semantic highlighting
Nathan Ridge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 19 01:24:40 PDT 2023
nridge updated this revision to Diff 506359.
nridge added a comment.
add test case
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D134827/new/
https://reviews.llvm.org/D134827
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
@@ -942,7 +942,15 @@
auto $LocalVariable_def[[s]] = $Operator[[new]] $Class[[Foo]]<$TemplateParameter[[T]]>();
$Operator[[delete]] $LocalVariable[[s]];
}
- )cpp"};
+ )cpp",
+ // Recursive UsingValueDecl
+ R"cpp(
+ template <int> class $Class_def[[X]] {
+ template <int> class $Class_def[[Y]] {
+ using $Class[[Y]]<0>::$Unknown_dependentName[[xxx]];
+ };
+ };
+ )cpp"};
for (const auto &TestCase : TestCases)
// Mask off scope modifiers to keep the tests manageable.
// They're tested separately.
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===================================================================
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -156,7 +156,7 @@
return HighlightingKind::Concept;
if (const auto *UUVD = dyn_cast<UnresolvedUsingValueDecl>(D)) {
auto Targets = Resolver->resolveUsingValueDecl(UUVD);
- if (!Targets.empty()) {
+ if (!Targets.empty() && Targets[0] != UUVD) {
return kindForDecl(Targets[0], Resolver);
}
return HighlightingKind::Unknown;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D134827.506359.patch
Type: text/x-patch
Size: 1477 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230319/52fc703a/attachment-0001.bin>
More information about the cfe-commits
mailing list