https://github.com/liepieshov created https://github.com/llvm/llvm-project/pull/164854
Skip /*static*/ annotation on function definitions to use the better defined declaration documentation. >From 52ea57527262a8bfaed1f67044cfcf3dbc479d8a Mon Sep 17 00:00:00 2001 From: Kostia Liepieshov <[email protected]> Date: Thu, 23 Oct 2025 17:31:45 +0000 Subject: [PATCH] [Autocomplete] skip static annotation comment Skip /*static*/ annotation on function definitions to use the better defined declaration documentation. --- .../clangd/unittests/HoverTests.cpp | 16 ++++++++++++++++ clang/lib/AST/ASTContext.cpp | 2 +- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp index 718c1bc5f355a..d0b88918894c0 100644 --- a/clang-tools-extra/clangd/unittests/HoverTests.cpp +++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -2019,6 +2019,22 @@ TEST(Hover, All) { HI.Definition = "class Foo {}"; HI.Documentation = "Forward class declaration"; }}, + { + R"cpp(// Function declaration ignore static annotation + void foo(); + /*static*/ void foo() {} + void g() { [[f^oo]](); } + )cpp", + [](HoverInfo &HI) { + HI.Name = "foo"; + HI.Kind = index::SymbolKind::Function; + HI.NamespaceScope = ""; + HI.Type = "void ()"; + HI.Definition = "void foo()"; + HI.Documentation = "Function declaration ignore static annotation"; + HI.ReturnType = "void"; + HI.Parameters = std::vector<HoverInfo::Param>{}; + }}, { R"cpp(// Function declaration void foo(); diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index 32c8f6209a693..caecab17cb81b 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -398,7 +398,7 @@ const RawComment *ASTContext::getRawCommentForAnyRedecl( continue; } const RawComment *RedeclComment = getRawCommentForDeclNoCache(Redecl); - if (RedeclComment) { + if (RedeclComment && RedeclComment->getRawText(SourceMgr) != "/*static*/") { cacheRawCommentForDecl(*Redecl, *RedeclComment); if (OriginalDecl) *OriginalDecl = Redecl; _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
