diff --git a/docs/building.dox b/docs/building.dox index fba160a11..4e7f2df01 100644 --- a/docs/building.dox +++ b/docs/building.dox @@ -19,7 +19,7 @@ slang requires the following tools in order to build: - C++20 compatible compiler. Minimum supported compiler versions: - GCC 10 - clang 16 - - XCode 14.3 + - Xcode 15 - MSVC support is tested only against the most recent update of VS 2022 @section building-start Quick Start diff --git a/source/ast/builtins/ConversionFuncs.cpp b/source/ast/builtins/ConversionFuncs.cpp index 75dbdd74f..d1cc389aa 100644 --- a/source/ast/builtins/ConversionFuncs.cpp +++ b/source/ast/builtins/ConversionFuncs.cpp @@ -9,20 +9,6 @@ #include "slang/ast/SystemSubroutine.h" #include "slang/ast/types/Type.h" -// TODO: remove once AppleClang finally adds support for this -template -inline Dest bit_cast(const Source& src) noexcept { - static_assert(sizeof(Dest) == sizeof(Source), - "bit_cast requires source and destination to be the same size"); - static_assert(std::is_trivially_copyable::value, - "bit_cast requires the destination type to be copyable"); - static_assert(std::is_trivially_copyable::value, - "bit_cast requires the source type to be copyable"); - Dest dst; - std::memcpy(&dst, &src, sizeof(Dest)); - return dst; -} - namespace slang::ast::builtins { class SignedConversionFunction : public SystemSubroutine { @@ -115,7 +101,7 @@ class RealToBitsFunction : public SimpleSystemSubroutine { if (!val) return nullptr; - return SVInt(64, bit_cast(val.real()), false); + return SVInt(64, std::bit_cast(val.real()), false); } }; @@ -133,7 +119,7 @@ class BitsToRealFunction : public SimpleSystemSubroutine { return nullptr; uint64_t i = val.integer().as().value_or(0); - return real_t(bit_cast(i)); + return real_t(std::bit_cast(i)); } }; @@ -150,7 +136,7 @@ class ShortRealToBitsFunction : public SimpleSystemSubroutine { if (!val) return nullptr; - return SVInt(32, bit_cast(val.shortReal()), false); + return SVInt(32, std::bit_cast(val.shortReal()), false); } }; @@ -168,7 +154,7 @@ class BitsToShortRealFunction : public SimpleSystemSubroutine { return nullptr; uint32_t i = val.integer().as().value_or(0); - return shortreal_t(bit_cast(i)); + return shortreal_t(std::bit_cast(i)); } }; diff --git a/source/numeric/ConstantValue.cpp b/source/numeric/ConstantValue.cpp index acecd5279..25b7c7502 100644 --- a/source/numeric/ConstantValue.cpp +++ b/source/numeric/ConstantValue.cpp @@ -564,7 +564,7 @@ bool operator==(const ConstantValue& lhs, const ConstantValue& rhs) { std::partial_ordering operator<=>(const ConstantValue& lhs, const ConstantValue& rhs) { return std::visit( - [&](auto&& arg) { + [&](auto&& arg) -> std::partial_ordering { constexpr auto unordered = std::partial_ordering::unordered; using T = std::decay_t; if constexpr (std::is_same_v) @@ -596,14 +596,10 @@ std::partial_ordering operator<=>(const ConstantValue& lhs, const ConstantValue& return arg <=> std::get(rhs.value); } else if constexpr (std::is_same_v) { - // TODO: clean this up once Xcode / libc++ get their act together if (!rhs.isString()) return unordered; - int cmp = arg.compare(rhs.str()); - return cmp < 0 ? std::partial_ordering::less - : cmp == 0 ? std::partial_ordering::equivalent - : std::partial_ordering::greater; + return arg <=> rhs.str(); } else if constexpr (std::is_same_v) { if (!rhs.isMap()) @@ -621,13 +617,7 @@ std::partial_ordering operator<=>(const ConstantValue& lhs, const ConstantValue& if (!rhs.isUnion()) return unordered; - // TODO: clean this up once Xcode / libc++ get their act together - auto& ru = rhs.unionVal(); - if (arg->activeMember < ru->activeMember) - return std::partial_ordering::less; - if (arg->activeMember > ru->activeMember) - return std::partial_ordering::greater; - return arg->value <=> ru->value; + return *arg <=> *rhs.unionVal(); } else { static_assert(always_false::value, "Missing case");