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/7] [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/7] 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/7] 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/7] 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. >From bd173869d9b263b012219a80bab57fe52ad93ec0 Mon Sep 17 00:00:00 2001 From: TPPPP <[email protected]> Date: Mon, 2 Mar 2026 13:49:02 +0800 Subject: [PATCH 5/7] add endline --- clang/test/Sema/gh182737.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/Sema/gh182737.c b/clang/test/Sema/gh182737.c index 3ba0170883b84..25d60acac9c4d 100644 --- a/clang/test/Sema/gh182737.c +++ b/clang/test/Sema/gh182737.c @@ -19,4 +19,4 @@ 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 +// expected-error@-4 {{function cannot return function type 'int (int)'}} >From c6173991dd63ee53eb0a22d28730c190ae3106e0 Mon Sep 17 00:00:00 2001 From: TPPPP <[email protected]> Date: Mon, 2 Mar 2026 15:10:24 +0800 Subject: [PATCH 6/7] add -ast-dump parameter --- clang/test/Sema/gh182737.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/clang/test/Sema/gh182737.c b/clang/test/Sema/gh182737.c index 25d60acac9c4d..7e70eb7972826 100644 --- a/clang/test/Sema/gh182737.c +++ b/clang/test/Sema/gh182737.c @@ -1,7 +1,10 @@ -// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -verify %s +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -ast-dump -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}} +#include <stdint.h> +#include <stdbool.h> + +// expected-warning@+3 2 {{empty paragraph passed to '@param' command}} +// expected-warning@+2 2 {{'@param' command used in a comment that is not attached to a function declaration}} /** * @param a */ @@ -16,7 +19,3 @@ typedef int my_int; * - 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)'}} >From ac07bdfd2faef7851206ade9a1e259edc21d26dd Mon Sep 17 00:00:00 2001 From: TPPPP <[email protected]> Date: Mon, 2 Mar 2026 16:08:41 +0800 Subject: [PATCH 7/7] update test --- clang/test/Sema/gh182737.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/clang/test/Sema/gh182737.c b/clang/test/Sema/gh182737.c index 7e70eb7972826..b076f57001704 100644 --- a/clang/test/Sema/gh182737.c +++ b/clang/test/Sema/gh182737.c @@ -1,8 +1,5 @@ // RUN: %clang_cc1 -fsyntax-only -Wdocumentation -ast-dump -verify %s -#include <stdint.h> -#include <stdbool.h> - // expected-warning@+3 2 {{empty paragraph passed to '@param' command}} // expected-warning@+2 2 {{'@param' command used in a comment that is not attached to a function declaration}} /** @@ -18,4 +15,4 @@ typedef int my_int; * - true: ok * - false: failure */ -typedef bool (*func_t)(uint8_t a); +typedef int (*func_t)(int a); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
