[clang] [llvm] [Clang] C++20 Coroutines: Introduce Frontend Attribute [[clang::coro_await_elidable]] (PR #99282)
Adrian Vogelsgesang via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 19 16:31:06 PDT 2024
================
@@ -8108,6 +8108,24 @@ but do not pass them to the underlying coroutine or pass them by value.
}];
}
+def CoroAwaitElidableDoc : Documentation {
+ let Category = DocCatDecl;
+ let Content = [{
+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 following conditions are all met:
+- callee coroutine function returns a type that is annotated with ``[[clang::coro_await_elidable]]``.
+- In caller coroutine, the return value of the callee is a prvalue or an xvalue, and
+- The temporary expression containing the callee coroutine object is immediately co_awaited.
----------------
vogelsgesang wrote:
```suggestion
- The callee coroutine function returns a type that is annotated with ``[[clang::coro_await_elidable]]``.
- In the caller coroutine, the return value of the callee is a prvalue or an xvalue.
- The temporary expression containing the callee coroutine object is immediately co_awaited.
```
(why remove the "and" in the 2nd bullet point? For consistency. Because otherwise, the 1st bullet point is also a self-contained sentence with a dot at its end)
https://github.com/llvm/llvm-project/pull/99282
More information about the cfe-commits
mailing list