From d87478c5f388d407ebbce78c9c1816ebb622fe16 Mon Sep 17 00:00:00 2001 From: Kevin Li Date: Thu, 19 Sep 2024 17:43:44 +0800 Subject: [PATCH] fix asan pipeline --- src/babylon/executor.h | 8 ++++---- src/babylon/executor.hpp | 15 +++++++++++---- test/test_executor.cpp | 8 ++++++++ 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/babylon/executor.h b/src/babylon/executor.h index 591a604..33f4eee 100644 --- a/src/babylon/executor.h +++ b/src/babylon/executor.h @@ -74,10 +74,10 @@ class Executor { // that coroutine, and can be used to wait and get the co_return value just // like use co_await inside another coroutine. template -//#if __cpp_concepts && __cpp_lib_coroutine - requires ((::std::is_invocable::value) && - (!CoroutineInvocable)) -//#endif // __cpp_concepts && __cpp_lib_coroutine +#if __cpp_concepts && __cpp_lib_coroutine + requires (::std::is_invocable::value && + !CoroutineInvocable) +#endif // __cpp_concepts && __cpp_lib_coroutine inline Future, F> execute(C&& callable, Args&&... args) noexcept; #if __cpp_concepts && __cpp_lib_coroutine diff --git a/src/babylon/executor.hpp b/src/babylon/executor.hpp index 62f42e0..76b9d7d 100644 --- a/src/babylon/executor.hpp +++ b/src/babylon/executor.hpp @@ -22,10 +22,10 @@ inline Executor::CoroutineHandle::CoroutineHandle( //////////////////////////////////////////////////////////////////////////////// // Executor begin template -//#if __cpp_concepts && __cpp_lib_coroutine - requires ((::std::is_invocable::value) && - (!CoroutineInvocable)) -//#endif // __cpp_concepts && __cpp_lib_coroutine +#if __cpp_concepts && __cpp_lib_coroutine + requires (::std::is_invocable::value && + !CoroutineInvocable) +#endif // __cpp_concepts && __cpp_lib_coroutine inline Future, F> Executor::execute( C&& callable, Args&&... args) noexcept { using R = ResultType; @@ -58,8 +58,15 @@ template requires CoroutineInvocable && Executor::IsPlainFunction inline Future, F> Executor::execute( C&& callable, Args&&... args) noexcept { +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wpragmas" +#pragma GCC diagnostic ignored "-Wunknown-warning-option" +#if ABSL_HAVE_ADDRESS_SANITIZER +#pragma GCC diagnostic ignored "-Warray-bounds" +#endif // ABSL_HAVE_ADDRESS_SANITIZER auto task = ::std::invoke(::std::forward(callable), ::std::forward(args)...); +#pragma GCC diagnostic pop return execute(::std::move(task)); } diff --git a/test/test_executor.cpp b/test/test_executor.cpp index f0b25a9..126f718 100644 --- a/test/test_executor.cpp +++ b/test/test_executor.cpp @@ -385,12 +385,15 @@ TEST_F(ExecutorTest, current_executor_mark_during_execution) { { struct S { static void function(Executor& e) { + (void) e; ASSERT_EQ(&e, ::babylon::CurrentExecutor::get()); } void member_function(Executor& e) { + (void) e; ASSERT_EQ(&e, ::babylon::CurrentExecutor::get()); } void operator()(Executor& e) { + (void) e; ASSERT_EQ(&e, ::babylon::CurrentExecutor::get()); } } s; @@ -402,6 +405,7 @@ TEST_F(ExecutorTest, current_executor_mark_during_execution) { thread_executor .execute( [](Executor& e) { + (void) e; ASSERT_EQ(&e, ::babylon::CurrentExecutor::get()); }, ::std::ref(thread_executor)) @@ -410,14 +414,17 @@ TEST_F(ExecutorTest, current_executor_mark_during_execution) { { struct S { static ::babylon::CoroutineTask<> run(Executor& e) { + (void) e; assert(&e == ::babylon::CurrentExecutor::get()); co_return; } ::babylon::CoroutineTask<> member_run(Executor& e) { + (void) e; assert(&e == ::babylon::CurrentExecutor::get()); co_return; } ::babylon::CoroutineTask<> operator()(Executor& e) { + (void) e; assert(&e == ::babylon::CurrentExecutor::get()); co_return; } @@ -428,6 +435,7 @@ TEST_F(ExecutorTest, current_executor_mark_during_execution) { thread_executor .execute( [&](Executor& e) -> CoroutineTask<> { + (void) e; assert(&e == ::babylon::CurrentExecutor::get()); co_return; },