The unconstrained implementation was removed, so qdoc was not able to
find a proper function. Provide a fake definition that matches what
qdoc expects. In this case the users shouldn't really care about the
constraints that the actual implementation has.
Amends 0c707c6ebece18677deaccccdfec5d48c587106f.
Found in Qt 6.9 API review.
Pick-to: 6.9
Change-Id: I6207b491fa94cc62d217af7dc7687923dc6971a4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
So that it allows overloading.
Also move the type T declaration into the function scope, as it
could never be used as a constraint anyway, and we do not want
users to pass custom type there.
Amends 0c707c6ebece18677deaccccdfec5d48c587106f.
Found in 6.9 API review.
Pick-to: 6.9
Change-Id: I086d65bdef7be2f9e0e67e96cc8a9ac76eaa5b0f
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Added the missing function declarations to the #if Q_QDOC part of the
header. Also fixed a typo in the std::unordered_map docs.
Amends 850d4895be565931d18c92e5e2f9a33b7f26de6d,
0c96528e8d43ad4309bdca14b179a5045984655a,
a9fe57fefaac0cb047e4c02e0b8c8f8327e0a58c,
and a8c9a5617c72ad2e55bf497df6ff2c2e141cbdef.
Found in Qt 6.9 API review.
Pick-to: 6.9
Change-Id: I792023b506e2afdbdca4bca3197887e50c98a788
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
qdebug.h includes many Qt and STL headers, so if you include a Qt header
you get all those transitive includes, which may affect build time.
- Where appropriate use the printf-like syntax of qDebug() and co.,
these don't need the QDebug streaming operators
- qfloat16 is used in an inline member function, so include it
explicitly
[ChangeLog][Potentially Source Incompatible Changes] Various Qt public
headers don't include QDebug any more; if you need QDebug's streaming
you'll have to include it in your code.
Task-number: QTBUG-132439
Pick-to: 6.9
Change-Id: I750587e17a3b38fa226cd3af8eaccc8da580f436
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
In preparation of adding QT_NO_SCOPED_POINTER, which would be rather
pointless for users if public headers continued to mention the type.
Pick-to: 6.9 6.8
Task-number: QTBUG-132213
Change-Id: Ib5a40a1b8defe1cfe858218bb25c422f900dfe6b
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
So they be SFINAE-ruled out when either the key or (for associative
containers) value types don't provide their debug-streaming operators
either.
Amends 850d4895be565931d18c92e5e2f9a33b7f26de6d,
0c96528e8d43ad4309bdca14b179a5045984655a,
a9fe57fefaac0cb047e4c02e0b8c8f8327e0a58c.
Fixes: QTBUG-132104
Task-number: QTBUG-130290
Pick-to: 6.9
Change-Id: I1d6703b1fdf6cfd03799fffd33191d8028ecc123
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Piggy-back on the recently-added, type-erased, std::tuple stream
operator to handle std::optional the same way.
While std::optional doesn't support the Tuple Protocol, and we
therefore can't use putTuple() directly, we can still use
putTupleImplImpl() if we set up its arguments manually.
[ChangeLog][Potentially Source-Incompatible Changes][QDebug] The
std::optional streaming operator is now a member of QDebug, not a free
function. This breaks users that rely on the exact definition of the
operator (e.g. `operator<<(d, opt)`). A backwards-compatible fix is to
call the operator with infix notation (d << opt) only, and to avoid
const QDebug objects.
Pick-to: 6.9
Change-Id: Ib040d65953ca9d3892aee5bdb597d6d30a9694b1
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Refinements of the stl containers based on the comments.
Fixes: QTBUG-131766
Change-Id: Iddca031a7b63cc24a3d4a1fdede02b8968e95be9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The stream insertion operator for QDebug is not overloaded
to handle std::multiset
Overload the stream insertion operator for QDebug
to handle std::multiset
[ChangeLog][QtCore][QDebug] Added support for std::multiset.
Fixes: QTBUG-131428
Change-Id: I7e3b721afe88d68c99c44c0d7cc9ee7711c169c8
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
The stream insertion operator for QDebug is not overloaded
to handle std::set
Overload the stream insertion operator for QDebug
to handle std::set
[ChangeLog][QtCore][QDebug] Added support for std::set.
Fixes: QTBUG-130574
Change-Id: I8e1589589c8f23318bf5073609995f7da4ea1108
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The stream insertion operator for QDebug is not overloaded
to handle std::unordered_set
Overload the stream insertion operator for QDebug
to handle std::unordered_set
[ChangeLog][QtCOre][QDebug] Added support for std::unordered_set.
Fixes: QTBUG-130481
Change-Id: I75a1f62f9ecb6b06ba45cc00d789cd3f3886b4c7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The stream insertion operator for QDebug is not overloaded
to handle std::unordered_map
Overload the stream insertion operator for QDebug
to handle std::unordered_map
[ChangeLog][QtCore][QDebug] Added support for std::unordered_map.
Fixes: QTBUG-130290
Change-Id: I96e82f90c310dcac4a6e4d35651fb1adb6d6293a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Unlike the existing one for std::pair, make the operator SCARY, using
the newly-added StreamTypeErased type-erasure (added in
5cdd1f594d26e1d4f84b00741be1ab7231458512).
[ChangeLog][QtCore][QDebug] Can now stream std::tuple.
Change-Id: I46670ac32eaee7f0ea5f4543ebcf59e19b394166
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
We don't need to enable nospace() if we stream but a single element
(nullopt). As a consequence, delay construction of the StateSaver
until we have determined that the optional is engaged.
Amends b7657ddccbe0a5ab1cdfc61ae6b7f0501dbfb24a.
Pick-to: 6.8
Change-Id: Id974dff078cb989b92f84b63bf14956a2fba32b2
Reviewed-by: David Faure <david.faure@kdab.com>
All other container stream operators use COMMA SP, while std::pair
used COMMA w/o SP.
Add the space to make the output a bit more readable, and for
consistency.
[ChangeLog][QtCore][QDebug] The output of a streamed std::pair has now
a space after the separating comma, like for other containers.
Change-Id: I01f83509038566cb9369d7ec743751b2ccc0903a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Like the 32-bit version, we add an explicitly-exported non-template
overload. And we can call the 64-bit implementation from the 32-bit one
to save in code generation inside QtCore.
Task-number: QTBUG-111926
Change-Id: I8a96935cf6c742259c9dfffd17e9928218333c04
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit removes the limitation on size that QFlags used to have,
allowing up to 64 bits. We could increase to 128 bits at this time, but
I'm choosing not to allow this yet, due to limitations in handling
128-bit integers in QMetaObject & QMetaObjectBuilder. The API wouldn't
be cross-platform.
This commit duplicates the tst_QFlags into a new tst_QFlags64. It
restores the tst_QVariant state to how it was before (even though it
doesn't actually test the QMetaEnum functionality).
[ChangeLog][QtCore][QFlags] Now supports 64-bit enumerations, with the
same syntax, including extraction into QMetaObject using the Q_FLAG and
Q_DECLARE_FLAGS markers. Note the QFlag helper class remains 32-bit
wide. Creation of a 64-bit QFlags from a generic integer can be achieved
by passing a std::in_place first argument.
Fixes: QTBUG-111926
Change-Id: Ifb754f0e28774c20aa7cfffd17e7fc1d16baf8e4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Instead of declaring three different template overloads (with an #if in
the middle), reduce to explicitly two:
1) one for the Q_ENUMs that aren't QFlags
2) one for QFlags
This does change how an enum that is a Q_FLAG gets printed: previously,
it was printed as itself, now it's printed as QFlags, even if no QFlags
are present.
Then use if constexpr for that second one to get the enumeration from
QMetaObject, if the flags are associated with a QMetaObject.
Change-Id: Ifb754f0e28774c20aa7cfffd17e7f8b9c68b292b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This applies to the Q_ENUM/Q_FLAGS overload of the debugging functions.
This prevents the sign-extension of a signed QFlags field when
converting to quint64, which would have resulted in 0x8000'0000 becoming
0xffff'ffff'8000'0000.
Right now, this is a no-op change because the implementation in
qt_QMetaEnum_flagDebugOperator() calls QMetaEnum::valueToKey(), which is
limited to int (32 bits).
Pick-to: 6.8
Change-Id: I8a96935cf6c742259c9dfffd17e998c3a0538146
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This change fixes three problems in the non-Q_ENUM overload. First, the
printing of the sign bit for a signed flag. This is correct, but
unexpected:
QFlags(0x1|0x2|-0x80000000)
By using unsigned types, we'll print instead:
QFlags(0x1|0x2|0x80000000)
Second, shifting into the sign bit is UB, so we remove the problem by
not having a sign bit at all.
Third, this provides an out-of-line non-template overload of the
implementation for unsigned QFlags, thereby avoiding an unnecessary
instantiation of the template function qt_QMetaEnum_flagDebugOperator()
in user code.
Pick-to: 6.8
Change-Id: I8a96935cf6c742259c9dfffd17e992caa315e1d3
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
QDebug::toBytes intends to pass the input object's address to its
nested implementation, but was calling operator& which does not work
with types that has a custom overload. Calling std::addressof fixes this
problem.
Task-number: QTBUG-127510
Change-Id: I63a682d7053ded7b9ee5eef2fa2da02cf0e76cce
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
QDebug::toString intends to pass the input object's address to its
nested implementation, but was calling operator& which does not work
with types that has a custom overload. Calling std::addressof fixes this
problem.
Fixes: QTBUG-127510
Pick-to: 6.8
Change-Id: Ie608f7b1a63c4032246b6ff98a3651695f0536ca
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
I've seen over and over again how test authors are plagued by the
impedance mismatch between their 8-bit actual data and the result of
QString::toString() being in UTF-16. They invariably ditch their 8-bit
inputs and go to QString, but the mere fact that they start out with
8-bit input and then run into problems means we have a gaping API hole
here. QTest::toString() also suffers from this.
So add the option to a) construct a QDebug object over a QByteArray
(already supported by underlying QTextStream) and b) to stream into
QByteArray like toString() streams into QString.
Finally, make QTest::toString() use the new toBytes() function instead
of the old toString() one.
This saves 1% (91122→90248) in tst_tostring exeutable size on
optimized Linux AMD64 GCC 9 builds.
[ChangeLog][QtCore][QDebug] Added ctor from QByteArray* and a static
toBytes() function.
Change-Id: I2b021513d6427a1a961f39e751eaf4faaf527ba8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Extract the non-template-dependent code into an out-of-line function
and pass the actual streaming operation as a callback.
Saves 4% (174811→167936) in executable size for tst_qdebug and 2.7%
(93639→91122) for tst_tostring on Linux GCC 9 AMD64 release builds.
Pick-to: 6.8
Change-Id: If232e5b26c66981ffcb614f1bdb7007c71e879bf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Their argument types are not faithful representations of a Stream
object, so ctors should not be implicit. Besides, the QDebug ctors
that delegate to these Stream ctors are explicit, too, with the same
arguments.
Pick-to: 6.8
Change-Id: I8048e26e890009cc8f6bc3ce49e2c01af1e89514
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
There are zero QDebug operators that take an rvalue RHS, so there's no
need to make toString() perfectly forwarding. It just causes four¹
different versions of the identical function to be instantiated. Not
all compilers can merge the binary representations and those that try,
violate the standard (same address for different functions).
¹ {rvalue, lvalue} × {const, non-const}
Fix by taking by cref.
Amends 40976532158fc49be45bb976455f48e98f9690cf.
[ChangeLog][Potentially Source-Incompatible Changes][QtCore][QDebug]
The toString() static function no longer allows the called
operator<<() to modify the argument. No Qt-provided operator<<() does
that, and operators that do are probably buggy.
Pick-to: 6.8
Change-Id: Iac1ee9d29f93fd4840b75ffe363d354a2d19a96e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Makes sense to collect the stuff in a similarly-named header, and it's
not like any of the QTypeTraits stuff was needed for QTypeInfo.
Makes #include <qtypeinfo.h> _much_ lighter again, at the expense of
qminmax.h now getting <variant>, <tuple> and <optional> instead, but
qminmax.h is much easier to avoid in Qt headers (just use the std
versions) than qtypeinfo.h.
[ChangeLog][QtCore][Potentially Source-Incompatible Changes] The
qtypeinfo.h header no longer transitively includes <optional>, <tuple>
and <variant>.
Task-number: QTBUG-97601
Pick-to: 6.8
Change-Id: Ied96113f38c1232fef3ec79847ee62f06c68f268
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Coverity correctly complains that we're copying the QDebug object when
calling print*Container() when we could have moved it into the helper.
So do move it.
Pick-to: 6.7 6.6 6.5
Coverity-Id: 406803
Coverity-Id: 407406
Coverity-Id: 408523
Coverity-Id: 408562
Coverity-Id: 418431
Coverity-Id: 424788
Coverity-Id: 425106
Coverity-Id: 426537
Coverity-Id: 427163
Coverity-Id: 428925
Coverity-Id: 444463
Change-Id: Ic80247f315a09fffe9363577dff1d1c781859304
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Found in API review.
Amends b7657ddccbe0a5ab1cdfc61ae6b7f0501dbfb24a.
Pick-to: 6.7
Change-Id: Ibdab7f51be09036659475bd76af28e8692235b9c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Replace the ad-hoc implementation of QTest::toString() in
tst_qglobal.cpp with a QDebug stream operator, so the
QTest::toString() fall-back to QDebug::toString() kicks in.
Since the ABI issues revolving around the new int128 types are not
known, yet, avoid baking the types into the ABI by a) making the
operators constrained templates¹ and b) passing though void* to the
exported helpers. These functions return an error message if Qt was
compiled without support for int128.
Use the Thiago Trick™ (leaving obviouly dead code around for the
compiler to remove without warning) to expose more code to more
compilers. This appears to work elsewhere in Qt, so I hope it does
here, too.
This completes the minimum qint128 support so we're able to debug code
and write tests that use these types.
¹ Templates, unlike inline member functions of wholly-exported
classes, never² become part of the ABI.
² <insert here the convoluted scenario under which this is false>
Fixes: QTBUG-117011
Change-Id: Ia4e56d26c6ffd18b7d69a7ceaed65b2211d258b2
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
QPair _is_ std::pair. If this wasn't a fake-definition under #ifdef
Q_QDOC, the compiler would have complained long ago.
Pick-to: 6.6 6.5
Change-Id: Idfe589ff13115d3d908572a17b849f634ec86787
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This avoids us committing to the QByteArray return value, which is
overkill for short strings. Instead, pull the streaming of the unit
behind the ABI boundary, so we're free to change the implementation to
either stream directly or use SSO'ed std::string.
Pick-to: 6.6
Change-Id: I10927acb9d64077d9018b667958ca16be218012a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
There were setters (quote(), noquote()), but, unlike
space()/nospace(), there was no getter.
Add the getter, and, for symmetry, a parametrized setter, too.
[ChangeLog][QtCore][QDebug] Added setQuoteStrings()/quoteStrings() to
access and manipulate the quote()/noquote() state.
Change-Id: I1b73138819b4d02726a6ef862c190206431ccebc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
It's a RAII class, and RAII classes should have only [[nodiscard]]
constructors.
Pick-to: 6.6
Task-number: QTBUG-104164
Change-Id: Ia83fa003677a839734208b12bde2c6287c1b79a3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
We should not export non-polymorophic classes wholesale. Only export
the non-inline functions instead.
There are no implicitly-declared special member functions in this
class that could cause problems, so we don't need to delay until Qt 7.
Pick-to: 6.6
Change-Id: I204d703498bf42465ea122d1f31c443ea439bd6e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
[ChangeLog][QtCore][QDebug] Added pretty formatting of C++ <chrono>
durations.
[ChangeLog][QtTest] Added pretty formatting of C++ <chrono> durations
for QCOMPARE expressions.
Change-Id: I3b169860d8bd41e9be6bfffd1757cc087ba957fa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
I got tired of being told off by the inanity 'bot for faithfully
reflecting existing #if-ery in new #if-ery. Retain only the
documentation and definition of the deprecated define.
Change-Id: I47f47b76bd239a360f27ae5afe593dfad8746538
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Make them templates, for two reasons:
- so they can accept std::pmr types and, in general, any basic_string
with custom allocators and char_traits
- to break overload ambiguities with the Qt string view types
Also, add the missing C++20 char8_t overloads.
Also, avoid creation of a QString in the sizeof(wchar_t) == 2 case
(Windows). Add a comment to optimize for the sizeof(wchar_t) != 2 case
later.
Found in API review.
Pick-to: 6.5
Change-Id: I30139520f582a38863a0936f8eca4b1ed33e37c8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
To allow the user to customize the C++ code that QDoc sees, so as to be
able to work-around some limitations on QDoc itself, QDoc defines two
symbols: Q_QDOC and Q_CLANG_QDOC, both of which are "true" during an
entire execution of QDoc.
At a certain point in time, QDoc allowed the user the choice between a
custom C++ parser and a Clang based one.
The Q_QDOC symbol would always be defined while the Q_CLANG_QDOC symbol
would be defined only when the Clang based parser was chosen.
In more recent times, QDoc always uses a Clang based parser, such that
both Q_CLANG_QDOC and Q_QDOC are always defined, making them equivalent.
To avoid using different symbols, and the possible confusion and
fragmentation that derives from it, all usages of Q_CLANG_QDOC are now
replaced by the equivalent usages of Q_QDOC.
Change-Id: I5810abb9ad1016a4c5bbea99acd03381b8514b3f
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
qExchange is one of the few remaining functionalities that have not been
moved out of qglobal. Given that std::exchange exists in the standard, we
can simply move to it everywhere...
...if it weren't for the fact that std::exchange is only constexpr in
C++20, and only has its noexceptness specified in (most likely) C++23.
Still, we want to move to the existing std functionality where
possible, to allow the removal of qglobal includes in lieu of something
more fine-grained in the future.
So leave any constexpr calls[1] alone for now (and observe that none of
our current usages cares about the conditional noexceptness), but
replace everything else.
[1] QScopedValueRollback' ctor and QExplicitlySharedDataPointerV2::take
Task-number: QTBUG-99313
Change-Id: I599cb9846cf319c7ffd3457130938347a75aad25
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Port two variables from int/uint to qsizetype/size_t. These don't
cause problems, because their possible ranges are limited, however,
int/uint variables are a code smell these days, so replace them
nonetheless.
[ChangeLog][QtCore][QDebug] Fixed issues on 64-bit platforms when
streaming containers (incl. strings) of more than 2Gi elements.
Pick-to: 6.4 6.3 6.2
Task-number: QTBUG-103525
Change-Id: Ica6c5a6a062990306280fb713c47adb2053b752d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>