Bug 1974917 - Fix TypeToString to automatically handle named/numbered int types. r=nbp,glandium a=RyanVM
`TypeToString` defines instances for all the numbered int types (like `int32_t`); unfortunately this can leave some of the named types (like `int`) out of the sequence depending on how the C headers define the numbered ones. There are additional instances for signed and unsigned long, which are needed on some platforms and would break the build on others; there is an `#ifdef` which attempts to handle that, but the result of all this is that CI can build for 32-bit x86 Linux but it fails when I try locally. This patch simplifies things and removes the `#ifdef` using a similar idea to bug 836438: the unspecialized `TypeToString` calls another function with its own set of specializations, with numbered types in the first layer and named types in the second.
This commit is contained in:
committed by
rvandermeulen@mozilla.com
parent
e7d692b3a1
commit
b5d80c4948
@@ -83,7 +83,12 @@ constexpr uint64_t safe_integer_unsigned() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
const char* TypeToString();
|
const char* TypeToStringFallback();
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline constexpr const char* TypeToString() {
|
||||||
|
return TypeToStringFallback<T>();
|
||||||
|
}
|
||||||
|
|
||||||
#define T2S(type) \
|
#define T2S(type) \
|
||||||
template <> \
|
template <> \
|
||||||
@@ -91,6 +96,12 @@ const char* TypeToString();
|
|||||||
return #type; \
|
return #type; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define T2SF(type) \
|
||||||
|
template <> \
|
||||||
|
inline constexpr const char* TypeToStringFallback<type>() { \
|
||||||
|
return #type; \
|
||||||
|
}
|
||||||
|
|
||||||
T2S(uint8_t);
|
T2S(uint8_t);
|
||||||
T2S(uint16_t);
|
T2S(uint16_t);
|
||||||
T2S(uint32_t);
|
T2S(uint32_t);
|
||||||
@@ -101,14 +112,15 @@ T2S(int32_t);
|
|||||||
T2S(int64_t);
|
T2S(int64_t);
|
||||||
T2S(char16_t);
|
T2S(char16_t);
|
||||||
T2S(char32_t);
|
T2S(char32_t);
|
||||||
#if defined(XP_DARWIN) || defined(XP_WIN) || defined(__wasm__)
|
T2SF(int);
|
||||||
T2S(long);
|
T2SF(unsigned int);
|
||||||
T2S(unsigned long);
|
T2SF(long);
|
||||||
#endif
|
T2SF(unsigned long);
|
||||||
T2S(float);
|
T2S(float);
|
||||||
T2S(double);
|
T2S(double);
|
||||||
|
|
||||||
#undef T2S
|
#undef T2S
|
||||||
|
#undef T2SF
|
||||||
|
|
||||||
template <typename In, typename Out>
|
template <typename In, typename Out>
|
||||||
inline void DiagnosticMessage(In aIn, char aDiagnostic[1024]) {
|
inline void DiagnosticMessage(In aIn, char aDiagnostic[1024]) {
|
||||||
|
|||||||
Reference in New Issue
Block a user