[clang] [coroutines] Introduce [[clang::coro_return_type]] and [[clang::coro_wrapper]] (PR #71945)

Ilya Biryukov via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 17 05:16:16 PST 2023


================
@@ -300,6 +300,11 @@ Attribute Changes in Clang
   to reduce the size of the destroy functions for coroutines which are known to
   be destroyed after having reached the final suspend point.
 
+- Clang now introduced ``[[clang::coro_return_type]]`` and ``[[clang::coro_wrapper]]``
+  attributes. A function returning a type marked with ``[[clang::coro_return_type]]``
+  should be a coroutine. A non-coroutine function marked with ``[[clang::coro_wrapper]]``
----------------
ilya-biryukov wrote:

NIT: I suggest spelling out more aggressively what enforcement this entails. Feel free to adopt or ignore any part of the wording below, just a suggestion:
```
...
must either be a coroutine or marked as `[[clang::coro_wrapper]]`. Clang will enforce this with an error.
This attribute helps analyzers to detect coroutines and opens up possibility to enforce extra invariants for certain coroutine library implementations.
```

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


More information about the cfe-commits mailing list