[clang] [Clang] Propagate elide safe context through [[clang::coro_must_await]] (PR #108474)

Adrian Vogelsgesang via cfe-commits cfe-commits at lists.llvm.org
Sat Sep 14 05:00:30 PDT 2024


================
@@ -8261,12 +8261,19 @@ def CoroAwaitElidableDoc : Documentation {
 The ``[[clang::coro_await_elidable]]`` is a class attribute which can be applied
 to a coroutine return type.
 
-When a coroutine function that returns such a type calls another coroutine function,
-the compiler performs heap allocation elision when the call to the coroutine function
-is immediately co_awaited as a prvalue. In this case, the coroutine frame for the
-callee will be a local variable within the enclosing braces in the caller's stack
-frame. And the local variable, like other variables in coroutines, may be collected
-into the coroutine frame, which may be allocated on the heap.
+When a coroutine function returns such a type, a direct call expression therein
+that returns a prvalue of a type attributed ``[[clang::coro_await_elidable]]``
+is said to be under a safe elide context if one of the following is true:
+- it is the immediate right-hand side operand to a co_await expression.
+- it is an argument to a [[clang::coro_must_await]] parameter or parameter pack
----------------
vogelsgesang wrote:

```suggestion
- it is an argument to a ``[[clang::coro_must_await]]`` parameter or parameter pack
```

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


More information about the cfe-commits mailing list