diff --git a/include/FunctionGuard.h b/include/FunctionGuard.h index 6b15f69..da19b5a 100644 --- a/include/FunctionGuard.h +++ b/include/FunctionGuard.h @@ -58,7 +58,7 @@ class FunctionGuard { public: FunctionGuard() = default; /// Default constructor - FunctionGuard(nullptr_t) /// Null-pointer constructor + FunctionGuard(std::nullptr_t) /// Null-pointer constructor { } FunctionGuard(tFn in_fn) /// Functor constructor @@ -80,7 +80,7 @@ class FunctionGuard in_other.Forget(); return *this; } - FunctionGuard& operator=(nullptr_t) noexcept /// Null-pointer assignment operator (calls Forget() to clear the functor) + FunctionGuard& operator=(std::nullptr_t) noexcept /// Null-pointer assignment operator (calls Forget() to clear the functor) { Forget(); return *this; diff --git a/include/Private/TasksCommonPrivate.h b/include/Private/TasksCommonPrivate.h index 984f867..8629ced 100644 --- a/include/Private/TasksCommonPrivate.h +++ b/include/Private/TasksCommonPrivate.h @@ -54,6 +54,12 @@ NAMESPACE_SQUID_END #define COROUTINE_OPTIMIZE_ON _Pragma("clang optimize on") #endif +#if defined(__clang__) +#define SQUID_FORCENOINLINE __attribute__((noinline)) +#else +#define SQUID_FORCENOINLINE +#endif + // False type for use in static_assert() [static_assert(false, ...) -> static_assert(static_false, ...)] #include template diff --git a/include/Task.h b/include/Task.h index 321097e..5d4fca7 100644 --- a/include/Task.h +++ b/include/Task.h @@ -10,6 +10,7 @@ /// @defgroup Awaiters Awaiters /// @brief Versatile task awaiters that offer utility to most projects +#include #include #include #include @@ -216,7 +217,7 @@ class Task Task() /// Default constructor (constructs an invalid handle) { } - Task(nullptr_t) /// Null-pointer constructor (constructs an invalid handle) + Task(std::nullptr_t) /// Null-pointer constructor (constructs an invalid handle) { } Task(std::shared_ptr in_taskInternal) /// @private @@ -224,6 +225,8 @@ class Task { AddRef(); } + // Heap elision crash on clang https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0981r0.html + SQUID_FORCENOINLINE Task(std::coroutine_handle in_coroHandle) /// @private : m_taskInternal(std::make_shared(in_coroHandle)) { @@ -240,7 +243,7 @@ class Task { // NOTE: No need to alter logical reference here (this is a move) } - Task& operator=(nullptr_t) noexcept /// Null-pointer assignment operator (makes the handle invalid) + Task& operator=(std::nullptr_t) noexcept /// Null-pointer assignment operator (makes the handle invalid) { RemoveRef(); // Remove logical reference from old internal task m_taskInternal = nullptr;