llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clangd Author: Maria Fernanda Guimarães (mafeguimaraes) <details> <summary>Changes</summary> This patch adds a `dyn_cast<RootSignatureAttr>` branch in `getHoverContents` to explicitly set `HI.Name` and `HI.Documentation` for the attribute, skipping the generic `printPretty` path and preventing the internal identifier from leaking. Added a corresponding unit test to verify the behavior. Fixes #<!-- -->214790 --- Full diff: https://github.com/llvm/llvm-project/pull/214955.diff 2 Files Affected: - (modified) clang-tools-extra/clangd/Hover.cpp (+7) - (modified) clang-tools-extra/clangd/unittests/HoverTests.cpp (+16) ``````````diff diff --git a/clang-tools-extra/clangd/Hover.cpp b/clang-tools-extra/clangd/Hover.cpp index a2f8b6418833d..0d6aa8cea9d17 100644 --- a/clang-tools-extra/clangd/Hover.cpp +++ b/clang-tools-extra/clangd/Hover.cpp @@ -1013,6 +1013,13 @@ std::optional<HoverInfo> getHoverContents(const SelectionTree::Node *N, // Generates hover info for attributes. std::optional<HoverInfo> getHoverContents(const Attr *A, ParsedAST &AST) { HoverInfo HI; + + if (const auto *RS = llvm::dyn_cast<RootSignatureAttr>(A)) { + HI.Name = "RootSignature"; + HI.Documentation = Attr::getDocumentation(A->getKind()).str(); + return HI; + } + HI.Name = A->getSpelling(); if (A->hasScope()) HI.LocalScope = A->getScopeName()->getName().str(); diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp index 02ce48c6dca95..3ae86a4b039f4 100644 --- a/clang-tools-extra/clangd/unittests/HoverTests.cpp +++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -5431,6 +5431,22 @@ TEST(Hover, HLSLRegisterAttributeRange) { } } +TEST(Hover, HLSLRootSignature) { + Annotations T(R"hlsl( + #define RS_CBV "CBV(b0)" + [^RootSignature(RS_CBV)] + void CS_ValidCBV() {} + )hlsl"); + + TestTU TU = TestTU::withCode(T.code()); + configureHLSL(TU); + auto AST = TU.build(); + auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr); + ASSERT_TRUE(H) << "Hover should have been returned for RootSignature!"; + EXPECT_EQ(H->Name, "RootSignature"); + EXPECT_EQ(H->Definition, ""); +} + } // namespace } // namespace clangd } // namespace clang `````````` </details> https://github.com/llvm/llvm-project/pull/214955 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
