11// RUN: %check_clang_tidy -std=c++20 %s misc-coroutine-hostile-raii %t \
22// RUN: -config="{CheckOptions: {\
33// RUN: misc-coroutine-hostile-raii.RAIITypesList: 'my::Mutex; ::my::other::Mutex', \
4- // RUN: misc-coroutine-hostile-raii.AllowedAwaitablesList: 'safe::awaitable; ::my::other ::awaitable' \
4+ // RUN: misc-coroutine-hostile-raii.AllowedAwaitablesList: 'safe::awaitable; ::transformable ::awaitable' \
55// RUN: }}"
66
77namespace std {
@@ -136,6 +136,9 @@ ReturnObject scopedLockableTest() {
136136 absl::Mutex no_warning_5;
137137}
138138
139+ // ================================================================================
140+ // Safe awaitable
141+ // ================================================================================
139142namespace safe {
140143 struct awaitable {
141144 bool await_ready () noexcept { return false ; }
@@ -150,6 +153,32 @@ ReturnObject RAIISafeSuspendTest() {
150153 co_await other{};
151154}
152155
156+ // ================================================================================
157+ // Safe transformable awaitable
158+ // ================================================================================
159+ struct transformable { struct awaitable {}; };
160+ using alias_transformable_awaitable = transformable::awaitable;
161+ struct UseTransformAwaitable {
162+ struct promise_type {
163+ UseTransformAwaitable get_return_object () { return {}; }
164+ std::suspend_always initial_suspend () { return {}; }
165+ std::suspend_always final_suspend () noexcept { return {}; }
166+ void unhandled_exception () {}
167+ std::suspend_always await_transform (transformable::awaitable) { return {}; }
168+ };
169+ };
170+
171+ auto retAwaitable () { return transformable::awaitable{}; }
172+ UseTransformAwaitable RAIISafeSuspendTest2 () {
173+ absl::Mutex a;
174+ co_await retAwaitable ();
175+ co_await transformable::awaitable{};
176+ co_await alias_transformable_awaitable{};
177+ }
178+
179+ // ================================================================================
180+ // Lambdas
181+ // ================================================================================
153182void lambda () {
154183 absl::Mutex no_warning;
155184 auto lambda = []() -> ReturnObject {
@@ -164,6 +193,9 @@ void lambda() {
164193 absl::Mutex no_warning_2;
165194}
166195
196+ // ================================================================================
197+ // Denylisted RAII
198+ // ================================================================================
167199template <class T >
168200ReturnObject raii_in_template (){
169201 T a;
0 commit comments