https://github.com/TPPPP72 updated 
https://github.com/llvm/llvm-project/pull/183274

>From 729ced162b23dc967cd528af16a704d9f98ecad1 Mon Sep 17 00:00:00 2001
From: TPPPP <[email protected]>
Date: Wed, 25 Feb 2026 20:56:53 +0800
Subject: [PATCH 1/4] [clang] Fix crash when parsing documentation comments
 with invalid declarations

---
 clang/lib/AST/RawCommentList.cpp | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/clang/lib/AST/RawCommentList.cpp b/clang/lib/AST/RawCommentList.cpp
index 3f9edc75311d4..91e7187e43581 100644
--- a/clang/lib/AST/RawCommentList.cpp
+++ b/clang/lib/AST/RawCommentList.cpp
@@ -202,6 +202,11 @@ const char *RawComment::extractBriefText(const ASTContext 
&Context) const {
 comments::FullComment *RawComment::parse(const ASTContext &Context,
                                          const Preprocessor *PP,
                                          const Decl *D) const {
+  // If the associated declaration is invalid, do not proceed with semantic
+  // analysis.
+  if (D && D->isInvalidDecl())
+    return nullptr;
+
   // Lazily initialize RawText using the accessor before using it.
   (void)getRawText(Context.getSourceManager());
 

>From 2314ebd28e18d3e500f52ec06680db9a28bc0c59 Mon Sep 17 00:00:00 2001
From: TPPPP <[email protected]>
Date: Wed, 25 Feb 2026 23:11:42 +0800
Subject: [PATCH 2/4] add test and releasenotes

---
 clang/docs/ReleaseNotes.rst |  1 +
 clang/test/Sema/gh182737.c  | 22 ++++++++++++++++++++++
 2 files changed, 23 insertions(+)
 create mode 100644 clang/test/Sema/gh182737.c

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cb1010aee1edd..573570a8f3fdb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -296,6 +296,7 @@ Bug Fixes in This Version
 - Fixed a ``-Winvalid-noreturn`` false positive for unreachable ``try`` blocks 
following an unconditional ``throw``. (#GH174822)
 - Fixed an assertion failure in the serialized diagnostic printer when it is 
destroyed without calling ``finish()``. (#GH140433)
 - Fixed an assertion failure caused by error recovery while extending a nested 
name specifier with results from ordinary lookup. (#GH181470)
+- Fixed a crash when parsing Doxygen ``@param`` commands attached to invalid 
declarations or non-function entities. (#GH182737)
 
 Bug Fixes to Compiler Builtins
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/clang/test/Sema/gh182737.c b/clang/test/Sema/gh182737.c
new file mode 100644
index 0000000000000..3ba0170883b84
--- /dev/null
+++ b/clang/test/Sema/gh182737.c
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -verify %s
+
+// expected-warning@+3 {{empty paragraph passed to '@param' command}}
+// expected-warning@+2 {{'@param' command used in a comment that is not 
attached to a function declaration}}
+/**
+ * @param a
+ */
+typedef int my_int;
+
+/**
+ * @brief A callback
+ *
+ * @param[in] a param1
+ * @return
+ *      - true: ok
+ *      - false: failure
+ */
+typedef bool (*func_t)(uint8_t a);
+// expected-error@-1 {{type specifier missing, defaults to 'int'; ISO C99 and 
later do not support implicit int}}
+// expected-error@-2 {{unknown type name 'uint8_t'}}
+// expected-error@-3 {{type specifier missing, defaults to 'int'; ISO C99 and 
later do not support implicit int}}
+// expected-error@-4 {{function cannot return function type 'int (int)'}}
\ No newline at end of file

>From 9685c6a1808be50ffd8e5a6ea3681b157d60981a Mon Sep 17 00:00:00 2001
From: TPPPP <[email protected]>
Date: Wed, 25 Feb 2026 23:42:15 +0800
Subject: [PATCH 3/4] move GH182737 release note to AST Handling

---
 clang/docs/ReleaseNotes.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 573570a8f3fdb..c5f20e54bfab2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -296,7 +296,6 @@ Bug Fixes in This Version
 - Fixed a ``-Winvalid-noreturn`` false positive for unreachable ``try`` blocks 
following an unconditional ``throw``. (#GH174822)
 - Fixed an assertion failure in the serialized diagnostic printer when it is 
destroyed without calling ``finish()``. (#GH140433)
 - Fixed an assertion failure caused by error recovery while extending a nested 
name specifier with results from ordinary lookup. (#GH181470)
-- Fixed a crash when parsing Doxygen ``@param`` commands attached to invalid 
declarations or non-function entities. (#GH182737)
 
 Bug Fixes to Compiler Builtins
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -318,6 +317,7 @@ Bug Fixes to C++ Support
 Bug Fixes to AST Handling
 ^^^^^^^^^^^^^^^^^^^^^^^^^
 - Fixed a bug where explicit nullability property attributes were not stored 
in AST nodes in Objective-C. (#GH179703)
+- Fixed a crash when parsing Doxygen ``@param`` commands attached to invalid 
declarations or non-function entities. (#GH182737)
 
 Miscellaneous Bug Fixes
 ^^^^^^^^^^^^^^^^^^^^^^^

>From 2f85754432ff128fa71e9ea84296bbc09a854f2d Mon Sep 17 00:00:00 2001
From: TPPPP <[email protected]>
Date: Mon, 2 Mar 2026 12:30:55 +0800
Subject: [PATCH 4/4] detail modification

---
 clang/lib/AST/RawCommentList.cpp | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/clang/lib/AST/RawCommentList.cpp b/clang/lib/AST/RawCommentList.cpp
index 91e7187e43581..6379a2a1fe6bd 100644
--- a/clang/lib/AST/RawCommentList.cpp
+++ b/clang/lib/AST/RawCommentList.cpp
@@ -202,9 +202,7 @@ const char *RawComment::extractBriefText(const ASTContext 
&Context) const {
 comments::FullComment *RawComment::parse(const ASTContext &Context,
                                          const Preprocessor *PP,
                                          const Decl *D) const {
-  // If the associated declaration is invalid, do not proceed with semantic
-  // analysis.
-  if (D && D->isInvalidDecl())
+  if (D->isInvalidDecl())
     return nullptr;
 
   // Lazily initialize RawText using the accessor before using it.

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to