[clang] [Sema] Instantiate destructors for initialized members (PR #128866)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 5 04:44:05 PST 2025


================
@@ -5283,6 +5283,102 @@ Sema::SetDelegatingInitializer(CXXConstructorDecl *Constructor,
   return false;
 }
 
+static void MarkFieldDestructorReferenced(Sema &S, SourceLocation Location,
+                                          FieldDecl *Field) {
+  if (Field->isInvalidDecl())
+    return;
+
+  // Don't destroy incomplete or zero-length arrays.
+  if (isIncompleteOrZeroLengthArrayType(S.Context, Field->getType()))
+    return;
+
+  QualType FieldType = S.Context.getBaseElementType(Field->getType());
+
+  const RecordType *RT = FieldType->getAs<RecordType>();
----------------
AaronBallman wrote:

```suggestion
  const auto *RT = FieldType->getAs<RecordType>();
```

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


More information about the cfe-commits mailing list