[libc-commits] [libc] 7cbcc58 - [libc] Change UInt integer conversion operators to use standard types.
Tue Ly via libc-commits
libc-commits at lists.llvm.org
Tue May 23 11:12:57 PDT 2023
Author: Tue Ly
Date: 2023-05-23T14:12:46-04:00
New Revision: 7cbcc581a5bf4b736579ec17cd87c0ae10ace516
URL: https://github.com/llvm/llvm-project/commit/7cbcc581a5bf4b736579ec17cd87c0ae10ace516
DIFF: https://github.com/llvm/llvm-project/commit/7cbcc581a5bf4b736579ec17cd87c0ae10ace516.diff
LOG: [libc] Change UInt integer conversion operators to use standard types.
This fixes an issue with missing `unsigned long` conversion on macOS.
Reviewed By: michaelrj
Differential Revision: https://reviews.llvm.org/D151234
Added:
Modified:
libc/src/__support/UInt.h
Removed:
################################################################################
diff --git a/libc/src/__support/UInt.h b/libc/src/__support/UInt.h
index a702aaad827b..d36d8f9a7299 100644
--- a/libc/src/__support/UInt.h
+++ b/libc/src/__support/UInt.h
@@ -77,18 +77,24 @@ template <size_t Bits> struct UInt {
val[i] = words[i];
}
- constexpr explicit operator uint64_t() const { return val[0]; }
+ constexpr explicit operator unsigned long long() const {
+ return static_cast<unsigned long long>(val[0]);
+ }
+
+ constexpr explicit operator unsigned long() const {
+ return static_cast<unsigned long>(val[0]);
+ }
- constexpr explicit operator uint32_t() const {
- return uint32_t(uint64_t(*this));
+ constexpr explicit operator unsigned int() const {
+ return static_cast<unsigned int>(val[0]);
}
- constexpr explicit operator uint16_t() const {
- return uint16_t(uint64_t(*this));
+ constexpr explicit operator unsigned short() const {
+ return static_cast<unsigned short>(val[0]);
}
- constexpr explicit operator uint8_t() const {
- return uint8_t(uint64_t(*this));
+ constexpr explicit operator unsigned char() const {
+ return static_cast<unsigned char>(val[0]);
}
constexpr explicit operator bool() const { return !is_zero(); }
More information about the libc-commits
mailing list