[clang] [coroutines][coro_lifetimebound] Detect lifetime issues with lambda captures (PR #77066)

Chuanqi Xu via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 15 18:15:24 PST 2024


================
@@ -15845,8 +15845,10 @@ void Sema::CheckCoroutineWrapper(FunctionDecl *FD) {
   RecordDecl *RD = FD->getReturnType()->getAsRecordDecl();
   if (!RD || !RD->getUnderlyingDecl()->hasAttr<CoroReturnTypeAttr>())
     return;
-  // Allow `get_return_object()`.
-  if (FD->getDeclName().isIdentifier() &&
+  // Allow some_promise_type::get_return_object().
+  // Since we are still in the promise definition, we can only do this
+  // heuristically as the promise may not be yet associated to a coroutine.
+  if (isa<CXXMethodDecl>(FD) && FD->getDeclName().isIdentifier() &&
       FD->getName().equals("get_return_object") && FD->param_empty())
     return;
----------------
ChuanqiXu9 wrote:

Got it. In this case, we can make it into a PendingXXX struct in Sema and we can check it in the end of the TU. But this is not required in this patch. If you don't want to address that in the current patch, let's leave a FIXME or a TODO here.

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


More information about the cfe-commits mailing list