================
@@ -768,6 +772,23 @@ struct GetReturnObjectManager {
         CGF.EmitAnyExprToMem(S.getReturnValue(), CGF.ReturnValue,
                              S.getReturnValue()->getType().getQualifiers(),
                              /*IsInit*/ true);
+        // If the return value has a non-trivial destructor, register a
+        // conditional cleanup that will destroy it if an exception is thrown
+        // before initial-await-resume. The cleanup is activated now and will
+        // be deactivated once initial_suspend completes normally.
+        if (QualType::DestructionKind DtorKind =
+                S.getReturnValue()->getType().isDestructedType()) {
----------------
ChuanqiXu9 wrote:

We can check for if the await initial_suspend may throw. If not, we don't need 
to insert the code, then we can avoid affecting optimizer.

And also it is better to insert a warning if the initial_suspend may  throw. We 
did the similar thing for final_suspend.

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

Reply via email to