diff --git a/clang-tools-extra/clangd/SemanticHighlighting.cpp b/clang-tools-extra/clangd/SemanticHighlighting.cpp --- a/clang-tools-extra/clangd/SemanticHighlighting.cpp +++ b/clang-tools-extra/clangd/SemanticHighlighting.cpp @@ -48,6 +48,17 @@ // And fallback to a generic kind if this fails. return HighlightingKind::Typedef; } + if (auto *UD = dyn_cast(D)) { + if (UD->shadow_size() == 0) + return llvm::None; // Should we add a new highlighting kind? + // Highlight the using decl as one of the underlying shadow decls. + UsingShadowDecl *Selected = *UD->shadow_begin(); + llvm::for_each(UD->shadows(), [&Selected](UsingShadowDecl *D) { + if (D->getLocation() < Selected->getLocation()) + Selected = D; + }); + return kindForDecl(Selected->getTargetDecl()); + } // We highlight class decls, constructor decls and destructor decls as // `Class` type. The destructor decls are handled in `VisitTagTypeLoc` (we // will visit a TypeLoc where the underlying Type is a CXXRecordDecl). diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp --- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp +++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp @@ -584,6 +584,11 @@ return $TemplateParameter[[T]]::$DependentName[[Field]]; } }; + )cpp", + // Highlighting the using decl as the underlying using shadow decl. + R"cpp( + void $Function[[foo]](); + using ::$Function[[foo]]; )cpp"}; for (const auto &TestCase : TestCases) { checkHighlightings(TestCase);