[clang] [llvm] [Clang] C++20 Coroutines: Introduce Frontend Attribute [[clang::coro_await_elidable]] (PR #99282)
Yuxuan Chen via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 7 22:08:09 PDT 2024
================
@@ -8119,6 +8119,35 @@ 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 call to the coroutine function
+is immediately co_awaited as a prvalue.
----------------
yuxuanchen1997 wrote:
> Then the question is, if the call is immediately co_awaited, in what cases it won't be a prvalue.
There probably aren't any. But I was still not confident of what "immediately" means in general.
The term "immediate subexpression" is defined to be a different meaning in the standard: https://eel.is/c++draft/intro.execution#3
But I don't have a strong opinion of this. Probably not ambiguous in this context. This isn't the first time we use an overloaded term and won't be the last either, but I still like interfacing with developer with the term `prvalue` better. In my experience it's better understood.
https://github.com/llvm/llvm-project/pull/99282
More information about the cfe-commits
mailing list