================ @@ -297,6 +297,26 @@ struct ReadySuspendResumeResult { bool IsInvalid; }; +// Adds [[clang::coro_wrapper]] and [[clang::coro_disable_lifetimebound]] +// attributes to `get_return_object`. +static void handleGetReturnObject(Sema &S, MemberExpr *ME) { + if (!ME || !ME->getMemberDecl() || !ME->getMemberDecl()->getAsFunction()) + return; + auto *MD = ME->getMemberDecl()->getAsFunction(); + auto *RetType = MD->getReturnType()->getAsRecordDecl(); + if (!RetType || !RetType->hasAttr<CoroReturnTypeAttr>()) + return; + // `get_return_object` should be allowed to return coro_return_type. + if (!MD->hasAttr<CoroWrapperAttr>()) + MD->addAttr( + CoroWrapperAttr::CreateImplicit(S.getASTContext(), MD->getLocation())); + // Object arg of `__promise.get_return_object()` is not lifetimebound. + if (RetType->hasAttr<CoroLifetimeBoundAttr>() && + !MD->hasAttr<CoroDisableLifetimeBoundAttr>()) + MD->addAttr(CoroDisableLifetimeBoundAttr::CreateImplicit( + S.getASTContext(), MD->getLocation())); +} + ---------------- ChuanqiXu9 wrote:
I didn't get this. Can't we just get the decl to `get_return_object` in `CoroutineStmtBuilder::makeReturnObject` and mark it as `CoroWrapperAttr` and `CoroDisableLifetimeBoundAttr`? Then we should be able to get rid of hard coding the `get_return_object` name in `Sema::CheckCoroutineWrapper` too? https://github.com/llvm/llvm-project/pull/77066 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits