diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-02-18 17:19:19 +0100 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-02-20 20:57:46 +0100 |
commit | ef6c4dfb1c14a55e480cc2c92555da4c93f01daf (patch) | |
tree | ecd9a17eb5adc4b6fed51f9dd9b0ee2af3f2da07 /src/corelib/text | |
parent | 29b18a017968cbc79dfcd21ea1622de823dc1596 (diff) |
QStringConverter/Encoder/Decoder: make move noexcept
The State state data member had non-noexcept move-SMFs, which were
inherited by the move-SMFs of QStringConverter, QStringEncoder and
QStringDecoder.
To fix, because it is called in the move-assignment operator, we need
to mark State::clear() as noexcept, and, since that can perform an
indirect call through clearFn, require the clearFn to be noexcept,
too.
The only users of clearFn were in Qt5Compat; a separate fix should
have been merged there by the time this lands.
Change-Id: Ibe8147970886526b6a479960050e108607b63874
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/text')
-rw-r--r-- | src/corelib/text/qstringconverter.cpp | 7 | ||||
-rw-r--r-- | src/corelib/text/qstringconverter_base.h | 8 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/corelib/text/qstringconverter.cpp b/src/corelib/text/qstringconverter.cpp index e6c2552348..199e85aaae 100644 --- a/src/corelib/text/qstringconverter.cpp +++ b/src/corelib/text/qstringconverter.cpp @@ -60,6 +60,11 @@ QT_BEGIN_NAMESPACE +static_assert(std::is_nothrow_move_constructible_v<QStringEncoder>); +static_assert(std::is_nothrow_move_assignable_v<QStringEncoder>); +static_assert(std::is_nothrow_move_constructible_v<QStringDecoder>); +static_assert(std::is_nothrow_move_assignable_v<QStringDecoder>); + enum { Endian = 0, Data = 1 }; static const uchar utf8bom[] = { 0xef, 0xbb, 0xbf }; @@ -1388,7 +1393,7 @@ QByteArray QLocal8Bit::convertFromUnicode(QStringView in, QStringConverter::Stat } #endif -void QStringConverter::State::clear() +void QStringConverter::State::clear() noexcept { if (clearFn) clearFn(this); diff --git a/src/corelib/text/qstringconverter_base.h b/src/corelib/text/qstringconverter_base.h index ac147892ee..f726d95b82 100644 --- a/src/corelib/text/qstringconverter_base.h +++ b/src/corelib/text/qstringconverter_base.h @@ -73,14 +73,14 @@ public: constexpr State(Flags f = Flag::Default) : flags(f), state_data{0, 0, 0, 0} {} ~State() { clear(); } - State(State &&other) + State(State &&other) noexcept : flags(other.flags), remainingChars(other.remainingChars), invalidChars(other.invalidChars), d{other.d[0], other.d[1]}, clearFn(other.clearFn) { other.clearFn = nullptr; } - State &operator=(State &&other) + State &operator=(State &&other) noexcept { clear(); flags = other.flags; @@ -92,7 +92,7 @@ public: other.clearFn = nullptr; return *this; } - Q_CORE_EXPORT void clear(); + Q_CORE_EXPORT void clear() noexcept; Flags flags; int internalState = 0; @@ -103,7 +103,7 @@ public: uint state_data[4]; void *d[2]; }; - using ClearDataFn = void (*)(State *); + using ClearDataFn = void (*)(State *) noexcept; ClearDataFn clearFn = nullptr; private: Q_DISABLE_COPY(State) |