https://github.com/Xinlong-Chen updated https://github.com/llvm/llvm-project/pull/183707
>From e7a2751770de3b029f1e55655c26c48450a31608 Mon Sep 17 00:00:00 2001 From: xinlongchen <[email protected]> Date: Fri, 27 Feb 2026 16:59:04 +0800 Subject: [PATCH] [clang] fix crash when evaluating __is_bitwise_cloneable on an invalid type --- clang/lib/AST/Type.cpp | 3 +++ clang/test/SemaCXX/builtin-is-bitwise-cloneable.cpp | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp index a85f08753a132..48c02303e9074 100644 --- a/clang/lib/AST/Type.cpp +++ b/clang/lib/AST/Type.cpp @@ -2934,6 +2934,9 @@ bool QualType::isBitwiseCloneableType(const ASTContext &Context) const { if (!RD) return true; + if (RD->isInvalidDecl()) + return false; + // Never allow memcpy when we're adding poisoned padding bits to the struct. // Accessing these posioned bits will trigger false alarms on // SanitizeAddressFieldPadding etc. diff --git a/clang/test/SemaCXX/builtin-is-bitwise-cloneable.cpp b/clang/test/SemaCXX/builtin-is-bitwise-cloneable.cpp index 1781cf48449f6..b092a6ff574a0 100644 --- a/clang/test/SemaCXX/builtin-is-bitwise-cloneable.cpp +++ b/clang/test/SemaCXX/builtin-is-bitwise-cloneable.cpp @@ -6,3 +6,9 @@ static_assert(__is_bitwise_cloneable(DynamicClass)); struct InComplete; // expected-note{{forward declaration}} static_assert(!__is_bitwise_cloneable(InComplete)); // expected-error{{incomplete type 'InComplete' used in type trait expression}} + +// Don't crash when the type has a member of invalid/unknown type. +struct ABC { // expected-note {{'ABC' declared here}} expected-note {{definition of 'ABC' is not complete until the closing '}'}} + ABCD ptr; // expected-error {{unknown type name 'ABCD'}} expected-error {{field has incomplete type 'ABC'}} +}; +static_assert(!__is_bitwise_cloneable(ABC)); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
