[clang] [CIR] Add support for normal cleanups (PR #149948)

Henrich Lauko via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 23 10:47:17 PDT 2025


================
@@ -369,6 +369,19 @@ void CIRGenFunction::emitImplicitAssignmentOperatorBody(FunctionArgList &args) {
                        s->getStmtClassName());
 }
 
+void CIRGenFunction::destroyCXXObject(CIRGenFunction &cgf, Address addr,
+                                      QualType type) {
+  const RecordType *rtype = type->castAs<RecordType>();
+  const CXXRecordDecl *record = cast<CXXRecordDecl>(rtype->getDecl());
+  const CXXDestructorDecl *dtor = record->getDestructor();
+  // TODO(cir): Unlike traditional codegen, CIRGen should actually emit trivial
+  // dtors which shall be removed on later CIR passes. However, only remove this
+  // assertion after we have a test case to exercise this path.
+  assert(!dtor->isTrivial());
+  cgf.emitCXXDestructorCall(dtor, Dtor_Complete, /*for vbase*/ false,
----------------
xlauko wrote:

```suggestion
  cgf.emitCXXDestructorCall(dtor, Dtor_Complete, /*forVirtualBase=*/ false,
```

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


More information about the cfe-commits mailing list