From d7799056fcc39065c03d88e352aae763e1d29f38 Mon Sep 17 00:00:00 2001 From: Axel Spoerl Date: Mon, 28 Mar 2022 18:09:15 +0200 Subject: Update documentation of enum Qt::DockWidgetArea Describe enum usage in QDockWidget::isAreaAllowed() as well as meaning of enum members. Change-Id: Ib88509feb001be27c11fd167c9009da50ce1b851 Reviewed-by: Volker Hilsheimer (cherry picked from commit 87762234a7de535935da29358a669d134266ae6a) Reviewed-by: Qt Cherry-pick Bot --- src/corelib/global/qnamespace.qdoc | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index 9755121273..dbb9469bba 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -827,14 +827,18 @@ /*! \enum Qt::DockWidgetArea - \value LeftDockWidgetArea - \value RightDockWidgetArea - \value TopDockWidgetArea - \value BottomDockWidgetArea - \value AllDockWidgetAreas - \value NoDockWidgetArea + Represents the areas a QDockWidget can be plugged to. + \note A floating dock widget with tabs can be docked anywhere. + + \value LeftDockWidgetArea The left dock area of a QMainWindow. + \value RightDockWidgetArea The right dock area of a QMainWindow. + \value TopDockWidgetArea The top dock area of a QMainWindow. + \value BottomDockWidgetArea The bottom dock area of a QMainWindow. + \value AllDockWidgetAreas All dock widget areas (default). + \value NoDockWidgetArea No dock widget areas. \omitvalue DockWidgetArea_Mask + \sa QDockWidget::setAllowedAreas, QDockWidget::isAreaAllowed */ /*! -- cgit v1.2.3 From df08a21fa4e7139d46ec68bcf264c922789c4f3a Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Sat, 1 May 2021 16:58:21 +0200 Subject: QRandom: drop a usage of std::is_literal_type It's deprecated/removed, and indeed doesn't check anything that it's not also already being checked by the previous line. Change-Id: Ic80ca43f390dd989ced69f196efa7313069e7c6d Reviewed-by: Thiago Macieira (cherry picked from commit 6351b5433da083890e47faa62e21fb40fd042c79) Reviewed-by: Marc Mutz --- src/corelib/global/qrandom.cpp | 1 - 1 file changed, 1 deletion(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qrandom.cpp b/src/corelib/global/qrandom.cpp index 0beb2eed4b..6f05158801 100644 --- a/src/corelib/global/qrandom.cpp +++ b/src/corelib/global/qrandom.cpp @@ -383,7 +383,6 @@ struct QRandomGenerator::SystemAndGlobalGenerators constexpr SystemAndGlobalGenerators g = {}; Q_UNUSED(g); - Q_STATIC_ASSERT(std::is_literal_type::value); #endif } -- cgit v1.2.3 From 00d4d1bbe9286c1bd5a1aae469f8ecc2d2b7ca28 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 2 May 2022 08:21:23 +0200 Subject: qcompilerdetection.h: add Q_CC_{GNU,MSVC,CLANG}_ONLY macros As the standard compilers on their respective platforms, other compilers tend to mask as Clang, GCC, or MSVC, leading to complicated code when you actually mean just one of these compilers: #if defined(Q_CC_GNU) && !defined(Q_CC_CLANG) && !defined(Q_CC_INTEL) This is particularly problematic when combined with version checks: #if defined(Q_CC_GNU) && Q_CC_GNU >= 900 will, e.g., not match Clang 10.0.0, which masks as GCC 4.2. The correct way (until a new kid on the block starts to mask as GCC, too) to check for GCC >= 9.0 atm is: #if defined(Q_CC_CLANG) || defined(Q_CC_INTEL) || !(defined(Q_CC_GNU) && Q_CC_GNU >= 900) The new macros make such checks intuitive and hard-to-misuse: #if defined(Q_CC_GNU_ONLY) && Q_CC_GNU >= 900 Use it in qcompilerdetection.h. Change-Id: Idcdf973fbc4708f58ed91c800be3d5e599e5b7e6 Reviewed-by: Thiago Macieira Reviewed-by: Qt CI Bot (cherry picked from commit c95fd3a7ce9c33f1fca1bce02e2f3b4cfdddc96c) Reviewed-by: Lars Knoll --- src/corelib/global/qcompilerdetection.h | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 1ced6c8fb0..eb9a1d327e 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2021 The Qt Company Ltd. +** Copyright (C) 2022 The Qt Company Ltd. ** Copyright (C) 2016 Intel Corporation. ** Contact: https://www.qt.io/licensing/ ** @@ -83,11 +83,14 @@ # endif #elif defined(_MSC_VER) +# define Q_CC_MSVC (_MSC_VER) +# define Q_CC_MSVC_NET +# define Q_CC_MSVC_ONLY Q_CC_MSVC # ifdef __clang__ +# undef Q_CC_MSVC_ONLY # define Q_CC_CLANG ((__clang_major__ * 100) + __clang_minor__) +# define Q_CC_CLANG_ONLY Q_CC_CLANG # endif -# define Q_CC_MSVC (_MSC_VER) -# define Q_CC_MSVC_NET # define Q_OUTOFLINE_TEMPLATE inline # define Q_COMPILER_MANGLES_RETURN_TYPE # define Q_FUNC_INFO __FUNCSIG__ @@ -106,6 +109,10 @@ # define QT_MAKE_CHECKED_ARRAY_ITERATOR(x, N) stdext::make_checked_array_iterator(x, size_t(N)) // Since _MSC_VER >= 1500 /* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */ # if defined(__INTEL_COMPILER) +# undef Q_CC_MSVC_ONLY +# ifdef Q_CC_CLANG_ONLY +# undef Q_CC_CLANG_ONLY +# endif # define Q_DECL_VARIABLE_DEPRECATED # define Q_CC_INTEL __INTEL_COMPILER # endif @@ -183,6 +190,7 @@ # else # define Q_CC_CLANG ((__clang_major__ * 100) + __clang_minor__) # endif +# define Q_CC_CLANG_ONLY Q_CC_CLANG # if __has_builtin(__builtin_assume) # define Q_ASSUME_IMPL(expr) __builtin_assume(expr) # else @@ -205,6 +213,7 @@ # endif # else /* Plain GCC */ +# define Q_CC_GNU_ONLY Q_CC_GNU # if Q_CC_GNU >= 405 # define Q_ASSUME_IMPL(expr) if (expr){} else __builtin_unreachable() # define Q_UNREACHABLE_IMPL() __builtin_unreachable() @@ -836,7 +845,7 @@ # define Q_DECL_UNUSED_MEMBER Q_DECL_UNUSED #endif -#if defined(Q_CC_GNU) && !defined(Q_CC_INTEL) && !defined(Q_CC_CLANG) +#if defined(Q_CC_GNU_ONLY) # define Q_COMPILER_RESTRICTED_VLA # define Q_COMPILER_THREADSAFE_STATICS # if Q_CC_GNU >= 403 -- cgit v1.2.3 From 8b968d2bf325b439107b2d5f91361cde9e421a8c Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Tue, 3 May 2022 12:06:25 +0200 Subject: Endian: Provide special integer bitfield unions Our previous approach of creating a union from individual special integer bitfields leads to undefined values because only one member of a union can be active at any given time. Compilers have finally caught up with us on that and have started removing "no-op" writes to members. The primary user of the special integer bitfield unions is qv4compileddata_p.h in qtdeclarative. We want our on-disk format of QML compilation units to be platform agnostic and space efficient. Task-number: QTBUG-99545 Change-Id: I24847bda2c364eb8ba75f074cde2a9bec25ced06 Reviewed-by: Fabian Kosmale Reviewed-by: Thiago Macieira (cherry picked from commit 38002df2065d3730defe3513f73088b444e68139) --- src/corelib/global/qendian_p.h | 193 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 193 insertions(+) (limited to 'src/corelib/global') diff --git a/src/corelib/global/qendian_p.h b/src/corelib/global/qendian_p.h index 926a055d35..ca64a35813 100644 --- a/src/corelib/global/qendian_p.h +++ b/src/corelib/global/qendian_p.h @@ -52,6 +52,7 @@ // #include +#include QT_BEGIN_NAMESPACE @@ -136,6 +137,198 @@ using qint32_be_bitfield = QBEIntegerBitfield; template using quint32_be_bitfield = QBEIntegerBitfield; +enum class QSpecialIntegerBitfieldInitializer {}; +constexpr QSpecialIntegerBitfieldInitializer QSpecialIntegerBitfieldZero{}; + +template +class QSpecialIntegerStorage +{ +public: + using UnsignedStorageType = typename std::make_unsigned::type; + + constexpr QSpecialIntegerStorage() = default; + constexpr QSpecialIntegerStorage(QSpecialIntegerBitfieldInitializer) : val(0) {} + constexpr QSpecialIntegerStorage(UnsignedStorageType initial) : val(initial) {} + + UnsignedStorageType val; +}; + +template +class QSpecialIntegerAccessor; + +template +class QSpecialIntegerConstAccessor +{ + Q_DISABLE_COPY(QSpecialIntegerConstAccessor) +public: + using Storage = const QSpecialIntegerStorage; + using Type = T; + using UnsignedType = typename std::make_unsigned::type; + + QSpecialIntegerConstAccessor(QSpecialIntegerConstAccessor &&) noexcept = default; + QSpecialIntegerConstAccessor &operator=(QSpecialIntegerConstAccessor &&) noexcept = default; + + operator Type() const noexcept + { + if (std::is_signed::value) { + UnsignedType i = S::fromSpecial(storage->val); + i <<= (sizeof(Type) * 8) - width - pos; + Type t = Type(i); + t >>= (sizeof(Type) * 8) - width; + return t; + } + return (S::fromSpecial(storage->val) & mask()) >> pos; + } + + bool operator!() const noexcept { return !(storage->val & S::toSpecial(mask())); } + + static constexpr UnsignedType mask() noexcept + { + return ((UnsignedType(1) << width) - 1) << pos; + } + +private: + template + friend class QSpecialIntegerBitfieldUnion; + friend class QSpecialIntegerAccessor; + + explicit QSpecialIntegerConstAccessor(Storage *storage) : storage(storage) {} + + friend bool operator==(const QSpecialIntegerConstAccessor &i, + const QSpecialIntegerConstAccessor &j) noexcept + { + return ((i.storage->val ^ j.storage->val) & S::toSpecial(mask())) == 0; + } + + friend bool operator!=(const QSpecialIntegerConstAccessor &i, + const QSpecialIntegerConstAccessor &j) noexcept + { + return ((i.storage->val ^ j.storage->val) & S::toSpecial(mask())) != 0; + } + + Storage *storage; +}; + +template +class QSpecialIntegerAccessor +{ + Q_DISABLE_COPY(QSpecialIntegerAccessor) +public: + using Const = QSpecialIntegerConstAccessor; + using Storage = QSpecialIntegerStorage; + using Type = T; + using UnsignedType = typename std::make_unsigned::type; + + QSpecialIntegerAccessor(QSpecialIntegerAccessor &&) noexcept = default; + QSpecialIntegerAccessor &operator=(QSpecialIntegerAccessor &&) noexcept = default; + + QSpecialIntegerAccessor &operator=(Type t) + { + UnsignedType i = S::fromSpecial(storage->val); + i &= ~Const::mask(); + i |= (UnsignedType(t) << pos) & Const::mask(); + storage->val = S::toSpecial(i); + return *this; + } + + operator Const() { return Const(storage); } + +private: + template + friend class QSpecialIntegerBitfieldUnion; + + explicit QSpecialIntegerAccessor(Storage *storage) : storage(storage) {} + + Storage *storage; +}; + +template +class QSpecialIntegerBitfieldUnion +{ +public: + constexpr QSpecialIntegerBitfieldUnion() = default; + constexpr QSpecialIntegerBitfieldUnion(QSpecialIntegerBitfieldInitializer initial) + : storage(initial) + {} + + constexpr QSpecialIntegerBitfieldUnion( + typename QSpecialIntegerStorage::UnsignedStorageType initial) + : storage(initial) + {} + + template + void set(typename A::Type value) + { + member() = value; + } + + template + typename A::Type get() const + { + return member(); + } + + typename QSpecialIntegerStorage::UnsignedStorageType data() const + { + return storage.val; + } + +private: + template struct Contains : std::false_type { }; + template struct Contains : std::is_same { }; + template + struct Contains + : std::conditional::value, std::true_type, Contains>::type {}; + + template + using IsAccessor = Contains; + + template + A member() + { + Q_STATIC_ASSERT(IsAccessor::value); + return A(&storage); + } + + template + typename A::Const member() const + { + Q_STATIC_ASSERT(IsAccessor::value); + return typename A::Const(&storage); + } + + QSpecialIntegerStorage storage; +}; + +template +using QLEIntegerBitfieldUnion + = QSpecialIntegerBitfieldUnion, Accessors...>; + +template +using QBEIntegerBitfieldUnion + = QSpecialIntegerBitfieldUnion, Accessors...>; + +template +using qint32_le_bitfield_union = QLEIntegerBitfieldUnion; +template +using quint32_le_bitfield_union = QLEIntegerBitfieldUnion; +template +using qint32_be_bitfield_union = QBEIntegerBitfieldUnion; +template +using quint32_be_bitfield_union = QBEIntegerBitfieldUnion; + +template +using qint32_le_bitfield_member + = QSpecialIntegerAccessor, pos, width, T>; +template +using quint32_le_bitfield_member + = QSpecialIntegerAccessor, pos, width, T>; +template +using qint32_be_bitfield_member + = QSpecialIntegerAccessor, pos, width, T>; +template +using quint32_be_bitfield_member + = QSpecialIntegerAccessor, pos, width, T>; QT_END_NAMESPACE -- cgit v1.2.3