================
@@ -1190,10 +1329,28 @@ mlir::Value CIRGenFunction::emitCXXNewExpr(const 
CXXNewExpr *e) {
     cgm.errorNYI(e->getSourceRange(), "emitCXXNewExpr: null check");
 
   // If there's an operator delete, enter a cleanup to call it if an
-  // exception is thrown.
-  if (e->getOperatorDelete() &&
-      !e->getOperatorDelete()->isReservedGlobalPlacementOperator())
-    cgm.errorNYI(e->getSourceRange(), "emitCXXNewExpr: operator delete");
+  // exception is thrown. If we do this, we'l be creating the result pointer
+  // inside a cleanup scope, either with a bitcast or an offset based on the
+  // array cookie size. However, we need to return that pointer from outside
+  // the cleanup scope, so we need to store it in a temporary variable.
+  bool useNewDeleteCleanup =
+      e->getOperatorDelete() &&
+      !e->getOperatorDelete()->isReservedGlobalPlacementOperator();
+  // These variables are only used if we use the new delete cleanup.
+  mlir::OpBuilder::InsertPoint beforeNewDeleteCleanup;
+  EHScopeStack::stable_iterator operatorDeleteCleanup;
+  Address resultPtr = Address::invalid();
----------------
erichkeane wrote:

This isn't used until ~30 lines later.  Do we intend the below region to use it 
at one point?  If not, is there value in having it this high in the code? 

https://github.com/llvm/llvm-project/pull/184707
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to