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/2] [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/2] 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 _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
