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 @@ -133,6 +133,10 @@ return HighlightingKind::TemplateParameter; if (isa(D)) return HighlightingKind::Concept; + if (isa(D)) { + // FIXME: We may be able to do better using HeuristicResolver. + return HighlightingKind::Unknown; + } return llvm::None; } llvm::Optional kindForType(const Type *TP) { @@ -228,6 +232,12 @@ return false; } +bool isDependent(const Decl *D) { + if (isa(D)) + return true; + return false; +} + // For a macro usage `DUMP(foo)`, we want: // - DUMP --> "macro" // - foo --> "variable". @@ -619,9 +629,14 @@ Tok.addModifier(HighlightingModifier::Static); if (isAbstract(Decl)) Tok.addModifier(HighlightingModifier::Abstract); + if (isDependent(Decl)) + Tok.addModifier(HighlightingModifier::DependentName); if (Decl->isDeprecated()) Tok.addModifier(HighlightingModifier::Deprecated); - if (R.IsDecl) + // Do not treat an UnresolvedUsingValueDecl as a declaration. + // It's more common to think of it as a reference to the + // underlying declaration. + if (R.IsDecl && !isa(Decl)) Tok.addModifier(HighlightingModifier::Declaration); } }, 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 @@ -688,6 +688,20 @@ @implementation $Class[[Foo]]($Namespace_decl[[Bar]]) @end )cpp", + // Member imported from dependent base + R"cpp( + template struct $Class_decl[[Base]] { + int $Field_decl[[member]]; + }; + template + struct $Class_decl[[Derived]] : $Class[[Base]]<$TemplateParameter[[T]]> { + using $Class[[Base]]<$TemplateParameter[[T]]>::$Unknown_dependentName[[member]]; + + void $Method_decl[[method]]() { + (void)$Unknown_dependentName[[member]]; + } + }; + )cpp", }; for (const auto &TestCase : TestCases) // Mask off scope modifiers to keep the tests manageable.