From: Mikhail R. Gadelha Date: Thu, 20 Apr 2023 16:00:04 +0000 (-0300) Subject: [libc] Make UInt trivially copyable X-Git-Tag: upstream/17.0.6~10924 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5db12eca1f70bb9c2dab33ff88dcccdfba75af6e;p=platform%2Fupstream%2Fllvm.git [libc] Make UInt trivially copyable This patch defaults the copy constructor and copy operator so it can be used with __builtin_bit_cast Reviewed By: sivachandra Differential Revision: https://reviews.llvm.org/D148794 --- diff --git a/libc/src/__support/UInt.h b/libc/src/__support/UInt.h index 2cbd3dfea6fb..c151689c3bbb 100644 --- a/libc/src/__support/UInt.h +++ b/libc/src/__support/UInt.h @@ -35,12 +35,9 @@ template struct UInt { static constexpr uint64_t low(uint64_t v) { return v & MASK32; } static constexpr uint64_t high(uint64_t v) { return (v >> 32) & MASK32; } - constexpr UInt() {} + constexpr UInt() = default; - constexpr UInt(const UInt &other) { - for (size_t i = 0; i < WORDCOUNT; ++i) - val[i] = other.val[i]; - } + constexpr UInt(const UInt &other) = default; template constexpr UInt(const UInt &other) { if (OtherBits >= Bits) { @@ -90,11 +87,7 @@ template struct UInt { return uint8_t(uint64_t(*this)); } - UInt &operator=(const UInt &other) { - for (size_t i = 0; i < WORDCOUNT; ++i) - val[i] = other.val[i]; - return *this; - } + UInt &operator=(const UInt &other) = default; constexpr bool is_zero() const { for (size_t i = 0; i < WORDCOUNT; ++i) {