A coroutine would generate following codes:
allocate memories; if (allocation fails) return promise-type::get_return_object_on_allocation_failure(); promise-type promise promise-constructor-arguments ; auto GRO = promise.get_return_object(); auto init_awaiter = promise.initial_suspend(); init_awaiter.await_ready(); init_awaiter.await_suspend(promise); try { init_awaiter.await_resume(); function-body } catch (...) { promise.unhandled_exception(); } co_await promise.final_suspend();
promise_type::final_suspend is guranteed to be noexcept.
So we could mark the coroutine as no-throw if all the followings are
no-throw:
- Promise Constructor.
- Parameter Copy/Move Constructor.
- Memory allocator
- promise-type::get_return_object_on_allocation_failure().
- promise.get_return_object().
- promise.initial_suspend(), init_awaiter.await_ready() and init_awaiter.await_suspend().
- promise.unhandled_exception()
Test Plan: check-llvm, cppcoro, folly
Please add a CoroutineStmtBitfields for this and NumParams. You can follow the pattern of e.g. LabelStmtBitfields.