Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMartin Hořeňovský2021-09-30 20:10:56 +0200
committerMartin Hořeňovský2021-09-30 20:11:22 +0200
commit1d79683ea8d64b2f4fffc68c66624096595c3575 (patch)
tree53f3198a7a088ff4baad048da7adfcad3f687821 /src
parenteb452e9b356de09bdb96273c035c40a8f4cb2ad3 (diff)
downloadcatch3-1d79683ea8d64b2f4fffc68c66624096595c3575.tar.gz
Add [[trivial_abi]] to Detail::unique_ptr when compiled with Clang
This decreases code size and improves performance of passing around `unique_ptr` instances by value somewhat. It virtually guarantees problems when combining code compiled with Clang and GCC, but that was never supported anyway.
Diffstat (limited to 'src')
-rw-r--r--src/catch2/internal/catch_unique_ptr.hpp11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/catch2/internal/catch_unique_ptr.hpp b/src/catch2/internal/catch_unique_ptr.hpp
index d3bc8417..6200542b 100644
--- a/src/catch2/internal/catch_unique_ptr.hpp
+++ b/src/catch2/internal/catch_unique_ptr.hpp
@@ -11,13 +11,22 @@
#include <cassert>
#include <type_traits>
+#if defined(__clang__) && defined(__has_attribute)
+# if __has_attribute(trivial_abi)
+# define TRIVIAL_ABI [[clang::trivial_abi]]
+# endif
+#endif
+#if !defined(TRIVIAL_ABI)
+# define TRIVIAL_ABI
+#endif
+
namespace Catch {
namespace Detail {
// reimplementation of unique_ptr for improved compilation times
// Does not support custom deleters (and thus does not require EBO)
// Does not support arrays
template <typename T>
- class unique_ptr {
+ class TRIVIAL_ABI unique_ptr {
T* m_ptr;
public:
constexpr unique_ptr(std::nullptr_t = nullptr):