summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/global
Commit message (Collapse)AuthorAgeFilesLines
...
* Add 'thread_local' definition as it is not available in C mode for VxWorksKrzysztof Sommerfeld2023-08-291-0/+5
| | | | | | Task-number: QTBUG-115777 Change-Id: I42c54ac2a34817f3b0a9b687ee282b97123b78c9 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Mark all of Qt as free of Q_FOREACH, except where it isn'tMarc Mutz2023-08-192-0/+4
| | | | | | | | | | | | | | | | | | | | | | The density of Q_FOREACH uses in this and some other modules is still extremely high, too high for anyone to tackle in a short amount of time. Even if they're not concentrated in just a few TUs, we need to make progress on a global QT_NO_FOREACH default, so grab the nettle and stick to our strategy: Mark the whole of Qt with QT_NO_FOREACH, to prevent new uses from creeping in, and whitelist the affected TUs by #undef'ing QT_NO_FOREACH locally, at the top of each file. For TUs that are part of a larger executable, this requires these files to be compiled separately, so add them to NO_PCH_SOURCES (which implies NO_UNITY_BUILD_SOURCES, too). In tst_qglobal.cpp and tst_qcollections.cpp change the comment on the #undef QT_NO_FOREACH to indicate that these actually test the macro. Task-number: QTBUG-115839 Change-Id: Iecc444eb7d43d7e4d037f6e155abe0e14a00a5d6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Make qYieldCpu() public APIThiago Macieira2023-07-251-0/+7
| | | | | | | | | | | Rewritten to be a bit simpler, added a few more yield/YieldProcessor alternatives, added RISC-V support. [ChangeLog][QtCore] Added qYieldCpu() function. Fixes: QTBUG-103014 Change-Id: I53335f845a1345299031fffd176f59032e7400f5 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* Add QStrongOrdering and QWeakOrderingDennis Oberst2023-07-251-0/+272
| | | | | | | | | | | | | | These new classes align with the criteria of std::strong_ordering and std::weak_ordering and were the missing types required by the three-way comparison operator. References: https://en.cppreference.com/w/cpp/utility/compare/strong_ordering https://en.cppreference.com/w/cpp/utility/compare/weak_ordering Change-Id: Ie6620ca98103800fd5504810dc5689c1dd1c2972 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Fix assert in qCleanupFuncInfo when using QDebug from a lambda with autoDavid Faure2023-07-111-0/+8
| | | | | | | | | | | | | | | | | | | | ASSERT: "size_t(i) < size_t(size())" in file qbytearray.h, line 492 due to info being emptied out completely and then the code does while ((info.at(0) == '*') info was empty because the recent fix "that wasn't the function argument list" would exit the loop with pos at end. Incidentally, this change fixes the fact that qCleanupFuncInfo was removing lambdas: main(int, char**)::<lambda()> became main(int, char**):: which was, well, shorted, but weird. Pick-to: 6.6 6.5 Change-Id: Ic7e8f21ea0df7ef96a3f25c4136a727dc0def207 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* CMake: Make corelib tests standalone projectsAlexandru Croitor2023-07-0517-0/+102
| | | | | | | | | | | | | | | | | | Add the boilerplate standalone test prelude to each test, so that they can be opened with an IDE without the qt-cmake-standalone-test script, but directly with qt-cmake or cmake. Boilerplate was added using the following scripts: https://git.qt.io/alcroito/cmake_refactor Manual adjustments were made where the code was inserted in the wrong location. Task-number: QTBUG-93020 Change-Id: I28b6d3815c5f43d2c33ea65764f6f3f8f129eaf3 Reviewed-by: Amir Masoud Abdol <amir.abdol@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* CMake: make tst_qlogging depend on qlogging_helperAhmad Samir2023-07-041-0/+2
| | | | | | | | | So that building tst_qlogging also builds qlogging_helper. Helps with local testing where you only build and run tst_qlogging instead of the whole repo. Change-Id: Ib36ff3e55e04794534d6cb7a23f243aae61d0005 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Suppress a couple of GCC warningsAhmad Samir2023-06-291-0/+3
| | | | | | | | | | | They're already suppressed for clang. -Wself-move was added in GCC 13.1, the CI still doesn't have that so wrap it in an "#if Q_CC_GNU >= 1301". Change-Id: I5c2ec78a5003485261b4e3125f85c5b78dd0db22 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Short live Q_NODISCARD_(CTOR_)X!Marc Mutz2023-06-221-4/+9
| | | | | | | | | | | | Wrappers around P1301 [[nodiscard("reason")]]. [ChangeLog][QtCore][Q_NODISCARD_X/Q_NODISCARD_CTOR_X] Added as wrappers around C++20 [[nodiscard("reason")]]. Task-number: QTBUG-114767 Change-Id: Ie566d9c9d500ef632c7e243af97081f83506a752 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Replace {add,sub,mul}_overload with q{Add,Sub,Mul}OverloadMarc Mutz2023-06-121-40/+40
| | | | | | | | | | | | | | | | | | | These APIs started out as private APIs in qnumeric_p.h, but have since been made pseudo-public in qnumeric.h. The qnumeric_p.h versions just forward to the qnumeric.h ones, so just use the latter. This is in preparation of removing the {add,sub,mul}_overflow versions, which, despite being defined in the unnamed namespace, don't sport the q prefix, so potentially clash with global symbols. The change is a simple textual search and replace, manually excluding qnumeric_p.h. Picking to 6.5 to avoid cherry-pick conflicts going forward. Pick-to: 6.6 6.5 Change-Id: Ic0f7c92f7c47923317109e8a9dc06fa66bdff2c2 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Short live Q_NODISCARD_CTORIvan Solovev2023-04-301-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ChangeLog][QtCore] Introduced Q_NODISCARD_CTOR which resolves to [[nodiscard]] attribute for constructors on compilers that support it, and does nothing on other compilers. Using [[nodiscard]] attribute on a constructor is a C++20 feature, however in practice it is supported on most of the compilers that we use in Qt 6. Clang generates a [-Wunused-value] warning, GCC and MinGW generate a [-Wunused-result] warnings, and MSVC generates a C4834 warning. However, there are some exceptions. The Integrity compiler provides the following warning: "tst_qglobal.cpp", line 699: warning #3435-D: the "nodiscard" attribute doesn't apply to constructors, destructors, or routines with void return type [[nodiscard]] explicit Test(int val) : m_val(val) {} The QNX compiler (QCC 8.3.0) and GCC 9.3.1 on OpenSUSE generate the [-Wattributes] warning: tst_qglobal.cpp: In member function 'void tst_QGlobal::nodiscardConstructor()': tst_qglobal.cpp:699:44: warning: 'nodiscard' attribute applied to 'tst_QGlobal::nodiscardConstructor()::Test::Test(int)' with void return type [-Wattributes] [[nodiscard]] explicit Test(int val) : m_val(val) {} These warnings will lead to build failures when compiled with -warnings-are-errors flag, so for these compilers the macro does not do anything. An attempt to use __attribute__((__warn_unused_result__)) was also unsuccessful on these compilers, so this patch goes for an easy solution, and simply checks __has_cpp_attribute(nodiscard) >= 201907L to decide if the attribute is supported or not. This commit also introduces a syntax-only test, and also applies the new macro to QMutexLocker, because not all platforms in the CI build and run unit tests. Fixes: QTBUG-104161 Change-Id: Ib4230661a5ad5e8af0d67b21b034486ebcd67562 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Short live q20::to_address!Marc Mutz2023-03-314-0/+173
| | | | | | | | | | | | An implementation of C++20 std::to_address, a prerequesite for QSpan<>. The test cases are inspired by libstdc++'s test suite, just to avoid missing some cases, but the to_address implementation is white-room. Fixes: QTBUG-108430 Change-Id: I4c092fdd7a56c0b279068e341bbf91a725ca3b1f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qmessagehandler: fix QtTest warnings about duplicate row namesThiago Macieira2023-02-231-3/+7
| | | | | | Pick-to: 6.5 Change-Id: Ieec322d73c1e40ad95c8fffd17464fcb2ca96f5f Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* Logging: fix crash when decoding a symbol that isn't a functionThiago Macieira2023-02-231-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | Saw this on my FreeBSD VM. The backtrace() function thought the nearest symbol to something was "_ZTSNSt3__110__function6__baseIFbPvS2_EEE", which decoded to typeinfo name for std::__1::__function::__base<bool (void*, void*)> The function pointer type inside parameter threw the decoder for a loop and caused it to crash with the failed assertion in qbytearray.h: inline char QByteArray::at(qsizetype i) const { Q_ASSERT(size_t(i) < size_t(size())); return d.data()[i]; } I noticed this - because tst_qtimer hung - because qFormatLogMessage deadlocked acquiring QMessagePattern::mutex - because the logging recursed - because qCleanupFuncinfo failed an assertion while formatting the backtrace (my QT_MESSAGE_PATTERN has %{backtrace}) - because QTimer::~QTimer -> QObject::killTimer printed a warning - because tst_QTimer::moveToThread produces warnings Pick-to: 5.15 6.2 6.4 6.5 Change-Id: Ieec322d73c1e40ad95c8fffd17464f86e9725991 Reviewed-by: Kai Köhne <kai.koehne@qt.io>
* tests: Remove remains of qmake conversion from CMakeLists.txt filesFriedemann Kleint2023-02-1714-29/+0
| | | | | | | Pick-to: 6.5 Change-Id: I8d106554bb86ac1ec9bb7a4083de4c376bcbab1d Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
* QTypeInfo: remove further usages of isPointer / isIntegralGiuseppe D'Angelo2022-12-301-2/+2
| | | | | | | In preparation to their deprecation / removal. Change-Id: Ia073a9f7caabbc06063a1e416b23cdb12788b283 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* tst_qlogging: Skip backtrace tests under ASanThiago Macieira2022-12-211-0/+2
| | | | | | | | | | | | ASan inserts a lot of function calls in between our calls, so they end up in the backtrace and cause unexpected results. Similar to c672f148dbf179f2e0ac94dfac7d329d50a3e4a3. Fixes: QTBUG-109559 Pick-to: 6.4 6.5 Change-Id: I69ecc04064514f939896fffd1732dd2bc0317ae4 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* tst_qlogging: don't skip all tests under static buildsThiago Macieira2022-12-211-1/+1
| | | | | | | | | We only need to skip the backtrace ones, because there's no library called "Qt6Core". Pick-to: 6.4 6.5 Change-Id: I69ecc04064514f939896fffd1732dd680058ba6e Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* tst_qlogging: fix preprocessor directivesThiago Macieira2022-12-211-7/+6
| | | | | | | | Reorganize them and fix the comment. Pick-to: 6.4 6.5 Change-Id: I69ecc04064514f939896fffd1732dd57203cb21f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Use qtversion.h instead of qlibraryinfo.hMarc Mutz2022-12-092-2/+2
| | | | | | | | | | | | ... where 50b05e3e2ad969abf4b939d5db2253380e47d775 originally added them. While qtversion.h is included in qglobal.h, using qtversion.h directly is a tiny step towards removing qglobal.h includes from our code-base, so don't let this opportunity go to waste. Change-Id: I28eaca1f4e250fc9e12e2ce6a6f94670a1d08dbe Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* qfloat16: make it a built-in metatypeThiago Macieira2022-11-281-0/+12
| | | | | | | | | | | I've reserved the IDs for int128, uint128, bfloat16, and float128, because the mask in qvariant.cpp's qIsNumericType() requires primitives to be less than 64 to operate properly. Added a QMetaType/QDataStream test to confirm it is indeed built-in. Change-Id: I3d74c753055744deb8acfffd17247f7f57bada02 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* qfloat16: add QTextStream & QDebug streaming operatorsThiago Macieira2022-11-281-0/+22
| | | | | Change-Id: Ieba79baf5ac34264a988fffd172655bdcaf12a59 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* qfloat16: add QDataStream testsThiago Macieira2022-11-281-0/+25
| | | | | | Change-Id: I3d74c753055744deb8acfffd172494bf935864b8 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* qfloat16: add support for native _Float16 (C2x extended floating point)Thiago Macieira2022-11-281-2/+2
| | | | | | | | | | | | | | | | | | | | The C++ equivalent is std::float16_t, defined in P1467[1], and is coming with GCC 13 both in native mode (for x86, using AVX512FP16) and in emulated mode. The C and C++ types will be the same type (<stdfloat> simply typedefs). qfloat16 will need to remain a wrapper with an integer member to keep ABI with previous Qt versions. Because it is a trivially-copyable small type, it gets currently passed in registers; the presence of the integer member means it gets passed in general-purpose registers, while a single _Float16 member would be passed in a floating-point register. See: https://gcc.godbolt.org/z/8fEendjff [1] https://wg21.link/p1467 Change-Id: I8a5b6425b64a4e319b94fffd161be56397cb48e6 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* QOperatingSystemVersion: add tests for the globalsThiago Macieira2022-10-281-0/+60
| | | | | | | Task-number: QTBUG-107907 Pick-to: 6.4 Change-Id: I07ec23f3cb174fb197c3fffd1721a85112010ec9 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QOperatingSystemVersion: fix ABI problem with dllimport on WindowsThiago Macieira2022-10-281-0/+30
| | | | | | | | | | | | | | | | | | | | | | I'm not entirely sure whether this is a toolchain bug or if this is intended. This commit ODR-uses all the static inline variables in QOperatingSystemVersion so they are added to the list of exported symbols in QtCore. On Windows: $ objdump -p bin/Qt6Core.dll | grep Windows11E [2534] _ZN23QOperatingSystemVersion9Windows11E On Linux: $ eu-readelf --dyn-syms lib/libQt6Core.so | grep Windows11E 1985: 0000000000575430 16 OBJECT GNU_UNIQUE PROTECTED 18 _ZN23QOperatingSystemVersion9Windows11E@@Qt_6 Pick-to: 6.4 Change-Id: Ia317fd249bcd80dbd02c198803a3a61178c0c219 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Long live Q_UNREACHABLE_RETURN()!Marc Mutz2022-10-151-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a combination of Q_UNREACHABLE() with a return statement. ATM, the return statement is unconditionally included. If we notice that some compilers warn about return after __builtin_unreachable(), then we can map Q_UNREACHABLE_RETURN(...) to Q_UNREACHABLE() without having to touch all the code that uses explicit Q_UNREACHABLE() + return. The fact that Boost has BOOST_UNREACHABLE_RETURN() indicates that there are compilers that complain about a lack of return after Q_UNREACHABLE (we know that MSVC, ICC, and GHS are among them), as well as compilers that complained about a return being present (Coverity). Take this opportunity to properly adapt to Coverity, by leaving out the return statement on this compiler. Apply the macro around the code base, using a clang-tidy transformer rule: const std::string unr = "unr", val = "val", ret = "ret"; auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(", ifBound(val, cat(node(val)), cat("")), ")"); auto ignoringSwitchCases = [](auto stmt) { return anyOf(stmt, switchCase(subStmt(stmt))); }; makeRule( stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)), nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))), {changeTo(node(unr), cat(makeUnreachableReturn, ";")), // TODO: why is the ; lost w/o this? changeTo(node(ret), cat(""))}, cat("use ", makeUnreachableReturn)) ); where nextStmt() is copied from some upstream clang-tidy check's private implementation and subStmt() is a private matcher that gives access to SwitchCase's SubStmt. A.k.a. qt-use-unreachable-return. There were some false positives, suppressed them with NOLINTNEXTLINE. They're not really false positiives, it's just that Clang sees the world in one way and if conditonal compilation (#if) differs for other compilers, Clang doesn't know better. This is an artifact of matching two consecutive statements. I haven't figured out how to remove the empty line left by the deletion of the return statement, if it, indeed, was on a separate line, so post-processed the patch to remove all the lines matching ^\+ *$ from the diff: git commit -am meep git reset --hard HEAD^ git diff HEAD..HEAD@{1} | sed '/^\+ *$/d' | recountdiff - | patch -p1 [ChangeLog][QtCore][QtAssert] Added Q_UNREACHABLE_RETURN() macro. Change-Id: I9782939f16091c964f25b7826e1c0dbd13a71305 Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from qAsConst() to std::as_const()Marc Mutz2022-10-112-2/+2
| | | | | | | | | | | | | | | | We've been requiring C++17 since Qt 6.0, and our qAsConst use finally starts to bother us (QTBUG-99313), so time to port away from it now. Since qAsConst has exactly the same semantics as std::as_const (down to rvalue treatment, constexpr'ness and noexcept'ness), there's really nothing more to it than a global search-and-replace, with manual unstaging of the actual definition and documentation in dist/, src/corelib/doc/ and src/corelib/global/. Task-number: QTBUG-99313 Change-Id: I4c7114444a325ad4e62d0fcbfd347d2bbfb21541 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
* Port from container.count()/length() to size()Marc Mutz2022-10-042-8/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is semantic patch using ClangTidyTransformator: auto QtContainerClass = expr(hasType(namedDecl(hasAnyName(<classes>)))).bind(o) makeRule(cxxMemberCallExpr(on(QtContainerClass), callee(cxxMethodDecl(hasAnyName({"count", "length"), parameterCountIs(0))))), changeTo(cat(access(o, cat("size"), "()"))), cat("use 'size()' instead of 'count()/length()'")) a.k.a qt-port-to-std-compatible-api with config Scope: 'Container'. <classes> are: // sequential: "QByteArray", "QList", "QQueue", "QStack", "QString", "QVarLengthArray", "QVector", // associative: "QHash", "QMultiHash", "QMap", "QMultiMap", "QSet", // Qt has no QMultiSet Change-Id: Ibe8837be96e8d30d1846881ecd65180c1bc459af Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QWinRegistryKey: refactorYuhang Zhao2022-09-143-61/+0
| | | | | | | | | | | | | | | | | | | | | | Refactor QWinRegistryKey to make it more modern and more usable from outside. Adjust the test for QWinRegistryKey to test the new functions, merged with the original test. Will port raw registry accessing code in QtBase to use this class in follow-up commits. This change is the first step. The long term goal is to port QSettings registry code to this class instead of using raw Win32 APIs, however, there's much more registry code in QSettings and migrate them to this class needs a large refactor, so jsut leave it for now. Will fix it in some future commit. Change-Id: Iada2adb41b4d58e1b658ff6870a4b31ace479d43 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Move qVersion() from qglobal.h to qlibraryinfo.hSona Kurazyan2022-09-012-0/+2
| | | | | | | | | | | | | | | Since qVersion() might be called also from C code, disable the parts of qlibraryinfo.h that are relevant only for C++ code if __cplusplus is not defined. [ChangeLog][Potentially Source-Incompatible Changes] qVersion() is moved from qglobal.h to qlibraryinfo.h, '#include <QtCore/QLibraryInfo>' needs to be added where it's used. Task-number: QTBUG-99313 Change-Id: I3363ef3fa4073114e5151cb3a2a1e8282ad42a4d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* QMetaObject: add a new, variadic invoke/invokeMethod/newInstanceThiago Macieira2022-08-301-2/+2
| | | | | | | | | | | | | | | | | [ChangeLog][QtCore][Meta Objects] The QMetaObject::invokeMethod() taking a method name by string, QMetaObject::newInstance(), and QMetaMethod::invoke() now support more than 10 arguments. [ChangeLog][QtCore][Meta Objects] The use of the Q_ARG and Q_RETURN_ARG macros is now optional with QMetaObject::invokeMethod(), QMetaObject::newInstance(), and QMetaMethod::invoke(): the type name will be obtained from the C++ type (the same as QMetaType). The function qReturnArg() can be used in place of the Q_RETURN_ARG macro. The macros are still useful in rare conditions where the type was typedef'ed from its original name. Change-Id: I36b24183fbd041179f2ffffd17022a2b48c7639b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QtBase tests: remove QT_DISABLE_DEPRECATED_UP_TO definesIvan Solovev2022-08-241-2/+0
| | | | | | | | | The value will be propagated from Qt build. Task-number: QTBUG-104858 Change-Id: Iae2c32c3037438f41b92f9ee28004f30eb4e3210 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* Change the license of all CMakeLists.txt and *.cmake files to BSDLucie Gérard2022-08-2318-18/+18
| | | | | | | Task-number: QTBUG-105718 Change-Id: I5d3ef70a31235868b9be6cb479b7621bf2a8ba39 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Rename QT_DISABLE_DEPRECATED_BEFORE -> QT_DISABLE_DEPRECATED_UP_TOIvan Solovev2022-08-191-2/+2
| | | | | | | | | | | | | | The new name describes the behavior in a better way. [ChangeLog][Build System] The QT_DISABLE_DEPRECATED_BEFORE macro is renamed to QT_DISABLE_DEPRECATED_UP_TO. The old name is deprecated, but is still recognized if it is defined during configuration and the new name is not defined. Task-number: QTBUG-104944 Change-Id: Ifc34323e0bbd9e3dc2f86c3e80d4d0940ebccbb8 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
* Tests: remove #define COMMAThiago Macieira2022-08-091-6/+7
| | | | | | | | | | Those were workarounds to passing a comma to a macro, but there are ways around it. The simplest is to just use variadic macros; another, which has been applied to Q_DECLARE_METATYPE for a long time, is to define an alias to the thing you're trying to use. Change-Id: Ie4bb662dcb274440ab8bfffd17097fbf0c53eabc Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* qputenv: defend against non-NUL-terminated QByteArray valuesMarc Mutz2022-08-051-1/+5
| | | | | | | | | | | | | | | | | | | | | | | The old code assumed that a QByteArray's data() is always NUL-terminated. Due to the conflation of owners and non-owners in QByteArray (but also in case we ever get efficient substringing), this is not always the case, e.g. QByteArray::fromRawData() does not ensure NUL-termination. From QString::utf16(), we learn that the condition to check for is QArrayData::isMutable(). After working around the fact that QByteArray::data_ptr() doesn't exist for const QBAs and that empty QBAs always refer to QByteArray::empty_, which is !isMutable(), we can detect this situation and re-allocate without introducing new API. This is the fix for Qt ≤ 6.4. For Qt 6.5, we'll port the function to QByteArrayView. Pick-to: 6.4 6.3 6.2 5.15 Fixes: QTBUG-105302 Change-Id: I3416535ab09d601e0e87b2767f2c024ba1217e64 Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Add license headers to cmake filesLucie Gérard2022-08-0318-0/+54
| | | | | | | | | | | | CMakeLists.txt and .cmake files of significant size (more than 2 lines according to our check in tst_license.pl) now have the copyright and license header. Existing copyright statements remain intact Task-number: QTBUG-88621 Change-Id: I3b98cdc55ead806ec81ce09af9271f9b95af97fa Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QMetaObject: rewrite invokeMethod()Thiago Macieira2022-07-281-3/+13
| | | | | | | | | | | | Use the QMetaMethodPrivate::invokeImpl() function we added in the last commit, without recreating the method signature. Instead, only do a comparison on the method name and allow invokeImpl() to decide whether this method can be called with the given arguments. This will allow invokeImpl() to have more flexibility in deciding if the arguments match, using the stored metatype information. Change-Id: I36b24183fbd041179f2ffffd17021a86484bfab6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* CMake: Don't use PUBLIC_LIBRARIES for tests and test helpersAlexandru Croitor2022-07-288-8/+8
| | | | | Change-Id: I9b7404e1d3a78fe0726ec0f5ce1461f6c209e90d Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
* function_ref test: Don't take reference of temporariesMårten Nordheim2022-06-201-5/+10
| | | | | | | | | | | | | When assigning the lambdas directly to a function_ref their lifetime is limited to that of the expression. Store them on the stack first to avoid the UB. Fixes: QTBUG-104419 Pick-to: 6.4 Change-Id: I3c85ac683b0bd7768b646dc9d0a1ed4dd173e6f3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Endian: Remove old special integer bitfieldsUlf Hermann2022-06-161-29/+0
| | | | | | | | | | | | | | The only way to use them was to put them in a union and then write all the members of the union to set the various bit ranges. As only one member of a union can be active at any time, the compiler is free to optimize those writes away, though. This has started happening in the wild now. As we have a replacement, we can remove the old and broken code now. Task-number: QTBUG-99545 Change-Id: I90718ec06662258d1c15220f54da9eed2186c5a5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Revert "qxp::function_ref: drop use of q23::invoke_r"Marc Mutz2022-06-141-0/+40
| | | | | | | | | | | | | | | | | | | | This reverts commit b9cce12e76796962e5e5ad0d5408370af56af459, which broke function_ref<void(int)> f = [](int i) { return i; }; ie. swallowing of return types. We could maybe implement the same without invoke_r, with the same manual if-constexpr that invoke_r has, but it would be a pointless duplication across the two thunks we have, so just use invoke_r. Add tests. Pick-to: 6.4 Task-number: QTBUG-103739 Change-Id: I6034f05d813c06a25e8058ded5b6b62f3ca858b4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Endian: Allow special bitfield union fields to cover the whole storageUlf Hermann2022-06-021-1/+11
| | | | | | | | This requires a different computation of the mask since we can't shift out of the storage type. Change-Id: Ife85ca3e0c5ca47f06988a397cc2f8a7e28ad0fe Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Short live qxp::function_ref!Marc Mutz2022-06-024-0/+243
| | | | | | | | | | | | | | | This is an implementation of function_ref, which has been proposed for inclusion into C++23, but has not been accepted, yet, which is why we place it in namespace qxp (for eXPerimental) instead of q23. The implementation is based on wg21.link/P0792r9, which, at the time of writing, is the latest revision of the paper. It will be used in both QTestLib and qmldom. Fixes: QTBUG-103739 Change-Id: I52723eca28f7ac02ce7ce51928361d81ae5c92b1 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* qglobal.h: use the GCC attribute for nothrow in C modeThiago Macieira2022-05-271-1/+2
| | | | | | | There's exactly one use in Qt: the qVersion() function. Change-Id: Ieb9a2aa1ea914b1b956bfffd16eff4b3b9e2119a Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* qglobal.h: #include <stdbool.h> in C modeThiago Macieira2022-05-181-9/+0
| | | | | | | It's C99 and we require C11. Change-Id: Ieb9a2aa1ea914b1b956bfffd16eff4556b99f976 Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Use SPDX license identifiersLucie Gérard2022-05-1619-538/+52
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* Remove remnants of the old Intel C++ compilerThiago Macieira2022-05-111-6/+0
| | | | | | | | | | | | | We don't support it any more. I don't think it has ever properly compiled Qt 6 (and it's no longer working for me against GCC 12's libstdc++ headers). If you report a bug against it, Intel support's first question is if you can try instead the new Clang/LLVM-based oneAPI C++ compiler. So we support only that one, which identifies itself as Q_CC_CLANG. Change-Id: I5ff8e16fcdcb4ffd9ab6fffd16eb57a092c8439e Reviewed-by: Marc Mutz <marc.mutz@qt.io>
* Endian: Provide special integer bitfield unionsUlf Hermann2022-05-071-1/+105
| | | | | | | | | | | | | | | | | 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. Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I24847bda2c364eb8ba75f074cde2a9bec25ced06 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>