[clang] [clang] fix crash when evaluating __is_bitwise_cloneable on an invalid type (PR #183707)

Corentin Jabot via cfe-commits cfe-commits at lists.llvm.org
Sat Feb 28 05:53:26 PST 2026


================
@@ -2940,18 +2940,28 @@ bool QualType::isBitwiseCloneableType(const ASTContext &Context) const {
   if (RD->mayInsertExtraPadding())
     return false;
 
+  auto isCycleBackToRD = [RD](QualType T) {
+    return !T.isNull() && !T->containsErrors() &&
+           T.getCanonicalType()->getAsRecordDecl() == RD;
----------------
cor3ntin wrote:

I think testing for incomplete or invalid types should be enough.

Did you test something like that 

```cpp
struct Bar;
struct Foo {
    Bar bar;
};
static_assert(__is_bitwise_cloneable(Bar)
```

https://github.com/llvm/llvm-project/pull/183707


More information about the cfe-commits mailing list