From f4bac3ca173be9f219099c04e76d6d62c4d0e19e Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Thu, 21 Mar 2024 10:48:05 +0100 Subject: 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 --- tests/auto/corelib/global/qglobal/tst_qglobal.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/auto/corelib/global/qglobal/tst_qglobal.cpp') diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 1a19048bbe..524212e933 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -930,6 +930,20 @@ struct Trivial1 static_assert(!QTypeInfo::isComplex); static_assert(QTypeInfo::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::isComplex); +static_assert(QTypeInfo::isRelocatable); +#endif +#endif + QT_END_NAMESPACE QTEST_APPLESS_MAIN(tst_QGlobal) -- cgit v1.2.3