This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGddfe13e757cb: [clangd] Produce semantic token for name referring to UnresolvedUsingValueDecl (authored by nridge).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D99052/new/ https://reviews.llvm.org/D99052 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 @@ -688,6 +688,20 @@ @implementation $Class[[Foo]]($Namespace_decl[[Bar]]) @end )cpp", + // Member imported from dependent base + R"cpp( + template <typename> struct $Class_decl[[Base]] { + int $Field_decl[[member]]; + }; + template <typename $TemplateParameter_decl[[T]]> + 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. Index: clang-tools-extra/clangd/SemanticHighlighting.cpp =================================================================== --- clang-tools-extra/clangd/SemanticHighlighting.cpp +++ clang-tools-extra/clangd/SemanticHighlighting.cpp @@ -133,6 +133,10 @@ return HighlightingKind::TemplateParameter; if (isa<ConceptDecl>(D)) return HighlightingKind::Concept; + if (isa<UnresolvedUsingValueDecl>(D)) { + // FIXME: We may be able to do better using HeuristicResolver. + return HighlightingKind::Unknown; + } return llvm::None; } llvm::Optional<HighlightingKind> kindForType(const Type *TP) { @@ -228,6 +232,12 @@ return false; } +bool isDependent(const Decl *D) { + if (isa<UnresolvedUsingValueDecl>(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<UnresolvedUsingValueDecl>(Decl)) Tok.addModifier(HighlightingModifier::Declaration); } },
Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp =================================================================== --- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp +++ 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 <typename> struct $Class_decl[[Base]] { + int $Field_decl[[member]]; + }; + template <typename $TemplateParameter_decl[[T]]> + 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. Index: clang-tools-extra/clangd/SemanticHighlighting.cpp =================================================================== --- clang-tools-extra/clangd/SemanticHighlighting.cpp +++ clang-tools-extra/clangd/SemanticHighlighting.cpp @@ -133,6 +133,10 @@ return HighlightingKind::TemplateParameter; if (isa<ConceptDecl>(D)) return HighlightingKind::Concept; + if (isa<UnresolvedUsingValueDecl>(D)) { + // FIXME: We may be able to do better using HeuristicResolver. + return HighlightingKind::Unknown; + } return llvm::None; } llvm::Optional<HighlightingKind> kindForType(const Type *TP) { @@ -228,6 +232,12 @@ return false; } +bool isDependent(const Decl *D) { + if (isa<UnresolvedUsingValueDecl>(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<UnresolvedUsingValueDecl>(Decl)) Tok.addModifier(HighlightingModifier::Declaration); } },
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits