Skip to content

Conversation

@liepieshov
Copy link

@liepieshov liepieshov commented Oct 23, 2025

Skip /*static*/ annotation on function definitions to use the better defined declaration documentation.

@github-actions
Copy link

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

@llvmbot llvmbot added clang Clang issues not falling into any other category clang-tools-extra clangd clang:frontend Language frontend issues, e.g. anything involving "Sema" labels Oct 23, 2025
@llvmbot
Copy link
Member

llvmbot commented Oct 23, 2025

@llvm/pr-subscribers-clangd
@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-tools-extra

Author: Kostiantyn Liepieshov (liepieshov)

Changes

Skip /*static*/ annotation on function definitions to use the better defined declaration documentation.


Full diff: https://github.com/llvm/llvm-project/pull/164854.diff

2 Files Affected:

  • (modified) clang-tools-extra/clangd/unittests/HoverTests.cpp (+16)
  • (modified) clang/lib/AST/ASTContext.cpp (+1-1)
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;

Skip /*static*/ annotation on function definitions to use the better
defined declaration documentation.
@liepieshov liepieshov force-pushed the cleanup-autocomplete-comments branch from 52ea575 to 8d5d646 Compare October 23, 2025 18:36
Copy link
Contributor

@Sterling-Augustine Sterling-Augustine left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is better than before. So LGTM.

@github-actions
Copy link

github-actions bot commented Oct 23, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

@liepieshov
Copy link
Author

Hi @4ast , @0x59616e , @4vtomat would you be able to review this change?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:frontend Language frontend issues, e.g. anything involving "Sema" clang Clang issues not falling into any other category clang-tools-extra clangd

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants