Skip to content

Commit 34598fd

Browse files
authored
[llvm][ItaniumDemangle] Use __LDBL_MANT_DIG__ for configuring demangling of long doubles (#135968)
Syncing in the changes from #134976 using the `cp-to-llvm.sh` script.
1 parent 419fa1b commit 34598fd

File tree

1 file changed

+13
-9
lines changed

1 file changed

+13
-9
lines changed

llvm/include/llvm/Demangle/ItaniumDemangle.h

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@
3838
DEMANGLE_NAMESPACE_BEGIN
3939

4040
template <class T, size_t N> class PODSmallVector {
41-
static_assert(std::is_trivial<T>::value,
42-
"T is required to be a trivial type");
41+
static_assert(std::is_trivially_copyable<T>::value,
42+
"T is required to be a trivially copyable type");
43+
static_assert(std::is_trivially_default_constructible<T>::value,
44+
"T is required to be trivially default constructible");
4345
T *First = nullptr;
4446
T *Last = nullptr;
4547
T *Cap = nullptr;
@@ -5739,14 +5741,16 @@ struct FloatData<double>
57395741
template <>
57405742
struct FloatData<long double>
57415743
{
5742-
#if defined(__mips__) && defined(__mips_n64) || defined(__aarch64__) || \
5743-
defined(__wasm__) || defined(__riscv) || defined(__loongarch__) || \
5744-
defined(__ve__)
5745-
static const size_t mangled_size = 32;
5746-
#elif defined(__arm__) || defined(__mips__) || defined(__hexagon__)
5747-
static const size_t mangled_size = 16;
5744+
#if __LDBL_MANT_DIG__ == 113 || __LDBL_MANT_DIG__ == 106
5745+
static const size_t mangled_size = 32;
5746+
#elif __LDBL_MANT_DIG__ == 53 || defined(_MSC_VER)
5747+
// MSVC doesn't define __LDBL_MANT_DIG__, but it has long double equal to
5748+
// regular double on all current architectures.
5749+
static const size_t mangled_size = 16;
5750+
#elif __LDBL_MANT_DIG__ == 64
5751+
static const size_t mangled_size = 20;
57485752
#else
5749-
static const size_t mangled_size = 20; // May need to be adjusted to 16 or 24 on other platforms
5753+
#error Unknown size for __LDBL_MANT_DIG__
57505754
#endif
57515755
// `-0x1.ffffffffffffffffffffffffffffp+16383` + 'L' + '\0' == 42 bytes.
57525756
// 28 'f's * 4 bits == 112 bits, which is the number of mantissa bits.

0 commit comments

Comments
 (0)