QTypeInfo: add detection for Clang's __is_trivially_relocatable
Types marked with [[clang::trivial_abi]] are considered to be trivially relocatable for Clang. This is ABI compatible, since in Qt 6 we can change the value of QTypeInfo::IsRelocatable "after the fact" -- it simply means that code that doesn't get recompiled is pessimized. Change-Id: I32e52bfb212c7919b2ebcf7832ede4404358330f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
parent
b20da0ba28
commit
f4bac3ca17
@ -23,7 +23,13 @@ class QDebug;
|
||||
namespace QtPrivate {
|
||||
|
||||
template <typename T>
|
||||
inline constexpr bool qIsRelocatable = std::is_trivially_copyable_v<T> && std::is_trivially_destructible_v<T>;
|
||||
inline constexpr bool qIsRelocatable = (std::is_trivially_copyable_v<T> && std::is_trivially_destructible_v<T>)
|
||||
#if defined(__has_builtin)
|
||||
#if __has_builtin(__is_trivially_relocatable)
|
||||
|| __is_trivially_relocatable(T)
|
||||
#endif
|
||||
#endif
|
||||
;
|
||||
|
||||
// Denotes types that are trivially default constructible, and for which
|
||||
// value-initialization can be achieved by filling their storage with 0 bits.
|
||||
|
@ -930,6 +930,20 @@ struct Trivial1
|
||||
static_assert(!QTypeInfo<Trivial1>::isComplex);
|
||||
static_assert(QTypeInfo<Trivial1>::isRelocatable);
|
||||
|
||||
#if defined(__has_builtin)
|
||||
#if __has_builtin(__is_trivially_relocatable) && __has_attribute(trivial_abi)
|
||||
struct [[clang::trivial_abi]] TrivialAbi1
|
||||
{
|
||||
~TrivialAbi1();
|
||||
TrivialAbi1(TrivialAbi1 &&);
|
||||
};
|
||||
static_assert(__has_builtin(__is_trivially_relocatable));
|
||||
static_assert(__is_trivially_relocatable(TrivialAbi1));
|
||||
static_assert(QTypeInfo<TrivialAbi1>::isComplex);
|
||||
static_assert(QTypeInfo<TrivialAbi1>::isRelocatable);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
QTEST_APPLESS_MAIN(tst_QGlobal)
|
||||
|
Loading…
x
Reference in New Issue
Block a user