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

Utkarsh Saxena via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 17 03:01:14 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;
----------------
usx95 wrote:

Thanks @ilya-biryukov for flagging the issue with Modules. Then I don't think it is wise to add these attributes. I will revert to the not-so-great heuristic of matching function names.

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


More information about the cfe-commits mailing list