Author: Nathan Ridge Date: 2023-03-19T04:30:33-04:00 New Revision: 7138e75d1bb5008b9278359dc83f05c668e104c2
URL: https://github.com/llvm/llvm-project/commit/7138e75d1bb5008b9278359dc83f05c668e104c2 DIFF: https://github.com/llvm/llvm-project/commit/7138e75d1bb5008b9278359dc83f05c668e104c2.diff LOG: [clangd] Avoid recursion on UnresolvedUsingValueDecl during semantic highlighting Fixes https://github.com/clangd/clangd/issues/1313 Differential Revision: https://reviews.llvm.org/D134827 Added: Modified: clang-tools-extra/clangd/SemanticHighlighting.cpp clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp index 19f79f793420d..2122cb86c2834 100644 --- a/clang-tools-extra/clangd/SemanticHighlighting.cpp +++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp @@ -156,7 +156,7 @@ std::optional<HighlightingKind> kindForDecl(const NamedDecl *D, 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; diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp index cba318df3d2fe..9a3ab30eafabb 100644 --- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp +++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp @@ -1045,7 +1045,15 @@ sizeof...($TemplateParameter[[Elements]]); auto $LocalVariable_def[[s]] = $Operator[[new]] $Class[[Foo]]$Bracket[[<]]$TemplateParameter[[T]]$Bracket[[>]](); $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. _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits