[llvm] [clang] [Coroutines] Introduce [[clang::coro_only_destroy_when_complete]] (PR #71014)

Timm Baeder via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 2 05:03:39 PDT 2023


================
@@ -777,6 +777,12 @@ void CodeGenFunction::EmitCoroutineBody(const CoroutineBodyStmt &S) {
 
   // LLVM require the frontend to mark the coroutine.
   CurFn->setPresplitCoroutine();
+
+  {
+    CXXRecordDecl *RD = FnRetTy->getAsCXXRecordDecl();
+    if (RD && RD->hasAttr<CoroOnlyDestroyWhenCompleteAttr>())
+      CurFn->setCoroDestroyOnlyWhenDone();
+  }
----------------
tbaederr wrote:

```suggestion
  if (const CXXRecordDecl *RD = FnRetTy->getAsCXXRecordDecl();
      RD && RD->hasAttr<CoroOnlyDestroyWhenCompleteAttr>())
    CurFn->setCoroDestroyOnlyWhenDone();
```

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


More information about the cfe-commits mailing list