================
@@ -6686,8 +6686,22 @@ Expr *Sema::MaybeCreateExprWithCleanups(Expr *SubExpr) {
assert(ExprCleanupObjects.size() >= FirstCleanup);
assert(Cleanup.exprNeedsCleanups() ||
ExprCleanupObjects.size() == FirstCleanup);
- if (!Cleanup.exprNeedsCleanups())
+ if (!Cleanup.exprNeedsCleanups()) {
+ // If we have a 'new' expression with a non-trivial destructor, we need to
+ // wrap it in an ExprWithCleanups to ensure that the destructor is called
+ // if the constructor throws.
+ if (auto *NE = dyn_cast<CXXNewExpr>(SubExpr)) {
----------------
ilovepi wrote:
oh, yeah, that's probably better. I'll give that a try.
https://github.com/llvm/llvm-project/pull/175817
_______________________________________________
llvm-branch-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits