https://github.com/mafeguimaraes created https://github.com/llvm/llvm-project/pull/214955
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 From 18797844e4ecb765fc11c3e2a711893105f00d02 Mon Sep 17 00:00:00 2001 From: Maria Fernanda Guimaraes <[email protected]> Date: Sat, 8 Aug 2026 10:55:44 +0000 Subject: [PATCH 1/2] Prevent RootSignature internal identifier leak on hover --- clang-tools-extra/clangd/Hover.cpp | 7 +++++++ 1 file changed, 7 insertions(+) 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(); From c349beea398f4984ce5e64070dac758019c29697 Mon Sep 17 00:00:00 2001 From: Maria Fernanda Guimaraes <[email protected]> Date: Sat, 8 Aug 2026 11:13:05 +0000 Subject: [PATCH 2/2] Add hover test for RootSignature attribute --- .../clangd/unittests/HoverTests.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) 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 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
