[clang] [clang-tools-extra] [Autocomplete] skip static annotation comment (PR #164854)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 23 10:35:20 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-tools-extra
Author: Kostiantyn Liepieshov (liepieshov)
<details>
<summary>Changes</summary>
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
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;
``````````
</details>
https://github.com/llvm/llvm-project/pull/164854
More information about the cfe-commits
mailing list