https://github.com/TPPPP72 updated https://github.com/llvm/llvm-project/pull/183274
>From d3a4133b99ad8bfd95645fde8f0a462437e36a1f 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 18949d1b1f9dfdd840f686543c1d778d3267c855 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 | 3 ++- clang/test/Sema/gh182737.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 clang/test/Sema/gh182737.c diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 5d07bfc210e05..7e4d218c9c129 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -315,9 +315,10 @@ Bug Fixes in This Version - Fix the result type of a binary operation where both operands are 'void' l-values. (#GH111300) - Fixed an assertion failure when evaluating ``_Countof`` on invalid ``void``-typed operands. (#GH180893) - Fixed an assertion failure in the serialized diagnostic printer when it is destroyed without calling ``finish()``. (#GH140433) +- Fixed a bug with multiple-include optimization (MIOpt) state not being preserved in some cases during lexing, which could suppress header-guard mismatch diagnostics and interfere with include-guard optimization. (#GH180155) - 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 ``#pragma clang attribute`` arguments for attributes that forbid arguments. (#GH182122) -- Fixed a bug with multiple-include optimization (MIOpt) state not being preserved in some cases during lexing, which could suppress header-guard mismatch diagnostics and interfere with include-guard optimization. (#GH180155) +- 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..b076f57001704 --- /dev/null +++ b/clang/test/Sema/gh182737.c @@ -0,0 +1,18 @@ +// RUN: %clang_cc1 -fsyntax-only -Wdocumentation -ast-dump -verify %s + +// 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 + */ +typedef int my_int; + +/** + * @brief A callback + * + * @param[in] a param1 + * @return + * - true: ok + * - false: failure + */ +typedef int (*func_t)(int a); >From b251d59a565ec48b9846accec97497911df0d5fc 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 | 1 + 1 file changed, 1 insertion(+) diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst index 7e4d218c9c129..52e6386741739 100644 --- a/clang/docs/ReleaseNotes.rst +++ b/clang/docs/ReleaseNotes.rst @@ -352,6 +352,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 95bdd36616a09372a479f5d8c7ed56318d4da18f 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
