summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
Commit message (Collapse)AuthorAgeFilesLines
* Use QArrayDataPointer to implement QByteArrayLars Knoll2019-12-082-0/+8
| | | | | Change-Id: I2ee28023c2dea9fc3160400112c59a47566a4868 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Use the QByteArray::DataPointer typedef instead of QByteArrayDataLars Knoll2019-12-081-1/+1
| | | | | | | | The goal here is to move things over to QArrayDataPointer. This prepares for it. Change-Id: I32f54a47594274799600c618f7341c200ceaa306 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Use <type_traits> to properly have QVector<T>::parameter_typeThiago Macieira2019-12-083-19/+23
| | | | | | | | | | | | That allows us to pass by value for all fundamental and pointer types. This requires some magic to remove methods taking a T&& to avoid ambiguous overloads for QVector<int/qsizetype>. Remove them for all cases where parameter_type is T, as copying or moving will do exactly the same thing for those types. Change-Id: I8133fecd3ac29bb8f6ae57376e680bc3d616afbf Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Optimize QArrayDataOps::compare for primitive typesLars Knoll2019-12-081-0/+5
| | | | | Change-Id: If726e3ee8a3635dcec2a316f1a829392de298634 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Final removal of the size and offset members from QArrayDataThiago Macieira2019-12-082-49/+6
| | | | | | | | Those members are not required anymore and now part of the object itself. Change-Id: If9eb5355ca8f2cf9528f6f63ca4e172acc9f9aed Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Inline the size and data pointers in QByteArrayThiago Macieira2019-12-081-5/+0
| | | | | Change-Id: I82feeb2c9bd2900f421fc0c8d78698b1e83db043 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Inline the size and begin pointer in QVectorThiago Macieira2019-12-084-638/+430
| | | | | | | | | | | Add QGenericArray to simplify operations. This class can be shared by other tool classes. If there is nothing else to share it, we can move the code onto qvector.h. The one candidate is QList. All tests pass and valgrind is good. Change-Id: Ieaa80709caf5f50520aa97312ab726396f5475eb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Various cleanups in qarraydataops and qarraydatapointerThiago Macieira2019-12-082-87/+304
| | | | | | | | Various cleanups. Add copyAppend overload for forward iterators and a insert overload for inserting n elements. Change-Id: Ic41cd20818b8307e957948d04ef6379368defa55 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Start moving QArrayData's size and data pointer to the main classThiago Macieira2019-12-085-89/+165
| | | | | | | | | | | | | This requires that the allocation functions return two pointers: the d pointer and the pointer to the actual data. Ported QArrayDataPointer & SimpleVector to the inlined size & data. For now, the size and offset members are not yet removed from QArrayData, to let QVector, QByteArray and QString compile unmodified. Change-Id: I8489300976723d75b8fd5831427b1e2bba486196 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add QArrayDataOps::moveAppend()Thiago Macieira2019-12-081-0/+56
| | | | | | | Same as copyAppend() but calls the move constructor Change-Id: I7de033f80b0e4431b7f1ffff13f9399e39b5fee4 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add the QArrayDataOps::parameter_type typedefThiago Macieira2019-12-081-2/+6
| | | | | | | | | It's a typedef meant to replace the "const T &" parameters (hence the name). But it's actually just a T for POD types, so we don't create references to them. Change-Id: I10c746d5e852c957ec84319712597478c4dc872c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Stop using the reference counter to store data stateThiago Macieira2019-12-084-19/+27
| | | | | | | | | | | Instead of using the reference count to store whether the data is sharable and whether the header is immutable, move the settings to the flags member. This allows us to save one comparison per deref() or needsDetach(). It also allows for the possibility of mutable data pointed to by a static header. Change-Id: Ie678a2ff2bb9bce73497cb6138b431c465b0f3bb Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add reference-count manipulation functions to QArrayData and hide refThiago Macieira2019-12-085-31/+51
| | | | | | | | The next change will stop using some values in the reference counter as settings from the data. Change-Id: I94df1fe643896373fac2f000fff55bc7708fc807 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Introduce the Mutable flag and move QArrayDataPointer::needsDetachThiago Macieira2019-12-084-9/+16
| | | | | | | | | | | | | | | | | | The Mutable flag now contains the information on whether the data this QArrayData points to is mutable. This decouples the mutability / immutability setting from the allocation and from the type of data, opening the way for mutable raw or foreign data. There are still plenty of places in the source code that check the size of the allocation when it actually wants d->isMutable(). Fixing this will require reviewing all the code, so is left for later. The needsDetach() function is moved to QArrayData and de-constified. It returns true when a reallocation is necessary if the data is to be modified. Change-Id: I17e2bc5a3f6ef1f3eba8a205acd9852b95524f57 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Make the AllocOptions flag to QVector::reallocData mandatoryThiago Macieira2019-12-081-8/+12
| | | | | | | This forces us to calculate the reallocation flags properly. Change-Id: I3486b193ad6732df666fc9ddad96831c9fbe068c Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Remove unused private methodLars Knoll2019-12-071-102/+0
| | | | | Change-Id: I3502c3c0451e7829fff0159a5d0891df34d04fe7 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* Introduce flags to indicate the QArrayData typeThiago Macieira2019-12-072-36/+63
| | | | | | | | | | | | | | | | | These flags allow us to determine what type of data QArrayData is carrying. There are currently only two supported types: - raw data type: constructed via fromRawData or static data - allocated data type: regular data done via heap allocation The QArrayData object is usually allocated on the heap, unless its own reference count is -1 (indicating static const QArrayData). Such object should have a type of RawDataType, since we can't call free(). Add GrowsBackward for completeness as well as the StaticDataFlags default for static data. Change-Id: Icc915a468a2acf2eae91a94e82451f852d382c92 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Introduce QArrayData::allocatedCapacity() and use it instead of d->allocThiago Macieira2019-12-073-37/+48
| | | | | | | | | | | | | | | | In almost all cases, use d->allocatedCapacity() or d->constAllocatedCapacity() instead of d->alloc, since they do the same thing (right now). In the future, the functions will be changed. There is a separate const version because most const code should not need to know the allocation size -- only mutating code should need to know that There are a few cases where d->alloc was replaced with a better alternative, like d->size. The one case that remains in the code will be replaced by a different test when it's available. Change-Id: I48135469db4caf150f82df93fff42d2309b23719 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Replace QArrayData::capacityReserved with a full flags fieldThiago Macieira2019-12-073-19/+12
| | | | | | | | | | | | | Instead of stealing one bit from the alloc field, let's use a full 32-bit for the flags. The first flag to be in the field is the CapacityReserved (even though the allocate() function will store some others there, not relevant for now). This is done in preparation for the need for more flags necessary anyway. Change-Id: I4c997d14743495e0d4558a6fb0a6042eb3d4975d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Rename QArrayData::AllocateOptions enum and update some flagsThiago Macieira2019-12-074-29/+31
| | | | | | | | | | | | | | | | Rename to QArrayData::ArrayOptions in preparation for these flags being in the array itself, instead of used just for allocating new ones. For that reason, rename QArrayData::Default to DefaultAllocationFlags. And introduce QArray::DefaultRawFlags to mean the flags needed for creating a raw (static) QArrayData. Also rename QArrayData::Grow to GrowsForward, so we may add GrowsBackward in the future. Change-Id: I536d9b34124f775d53cf810f62d6b0eaada8daef Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Add QArrayData::sharedNullData()Thiago Macieira2019-12-071-0/+12
| | | | | | | | | | | | | Just to simplify a few operations, like detecting when a QChar* or char* coming from a QString or QByteArray, respectively, were null data. While you're not supposed to dereference the pointer returned by QVector::data() unless you know that the array is non-empty, that is permitted for QString and QByteArray. That is, QString().constData() must return a valid pointer to a null QChar. Change-Id: I80b4b62f203dc841e5c99c20c51d92ca576e4bfe Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Tell the compiler that QArrayData::allocate allocates memoryThiago Macieira2019-12-071-1/+5
| | | | | | | | | | ICC, GCC and Clang support __attribute__((malloc)) that tells them that the function returns newly allocated memory which doesn't alias anything else. Though technically we may return memory that has already been used (the shared null or such), that should not be a problem. Change-Id: Id3d5c7bf4d4c45069621ffff13f7f81f8b08ea3d Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Tell the compiler that QArrayData returns aligned pointersThiago Macieira2019-12-071-4/+11
| | | | | | | | | | | GCC 4.9 and later support the __attribute__((alloc_align)) attributes that indicate the alignment of the data. To make it work on GCC since 4.7 and Clang as of 3.6, we instead use __builtin_assume_aligned(). I don't know which version of ICC first implemented this, but ICC 15 does and it also reports itself as GCC 4.9. Change-Id: I58bd914b9bdd0ed3349ba56fa78220ab06114852 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-12-043-4/+3
|\ | | | | | | Change-Id: I4134c0c6b6c9911950f58b3b5c86e789d28a185b
| * Merge remote-tracking branch 'origin/5.14' into 5.15Ulf Hermann2019-12-032-0/+2
| |\ | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/serialization/qcborvalue.cpp Change-Id: I675a3029955c96e81a33ed9d98b72b55b6784b52
| | * Silence intel compiler warning about float comparisonOlivier Goffart2019-11-282-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | Add the equivalent intel warning macro in public header where there was already the macro for -Wfloat-equal Change-Id: I8f20400f0b95c8f3857fa7a0a33464c8c34d5c0e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * | Workaround warning in QHash::uniteAlbert Astals Cid2019-12-021-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The warning pragmas don't work in gcc due to the fact this is a template. I've been told that unite() will disappear but meanwhile i think it's better if we simply don't give a warning that people can't protect themselves against Change-Id: I358e629be86e0e675ef3e49a7fbc4f7f65ae97f6 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
* | | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-11-254-21/+241
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qhash.h src/gui/kernel/qevent.h src/widgets/kernel/qshortcut.cpp src/widgets/kernel/qshortcut.h Change-Id: If61c206ee43ad1d97f5b07f58ac93c4583ce5620
| * | RDRAND test: also disable if RDRAND produced only three samplesThiago Macieira2019-11-181-1/+1
| | | | | | | | | | | | | | | | | | | | | It's unlikely, since we do 64-bit RDRAND on 64-bit machines. Change-Id: I8d95fbaf90e842b9b44dfffd15cd684a98a7ff50 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| * | Avoid erroneous creation of QScopedValueRollback objectsSimon Hausmann2019-11-081-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Mark the class as [[nodiscard]] to ensure that instances are given names and do not destruct (roll back) immediately. This avoids accidental code like this: QScopedValueRollback<Foo>(bar, baz); which rolls back instantly, when it should be QScopedValueRollback<Foo> blah(bar, baz); which rolls back at the end of the scope. Change-Id: I00269fe325b804078bd0a9d5058c941af7ba5597 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
| * | Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-11-081-1/+1
| |\| | | | | | | | | | Change-Id: I963b5f48b5d6f3500ca379fbd7f1a4290b570175
| | * Merge remote-tracking branch 'origin/5.13' into 5.14Qt Forward Merge Bot2019-11-061-1/+1
| | |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: .qmake.conf mkspecs/features/mac/default_post.prf src/corelib/tools/qsimd_p.h src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm util/qfloat16-tables/gen_qfloat16_tables.cpp Change-Id: If48fa8a3bc3c983706b609a6d3822cb67c1352a4
| | | * Merge remote-tracking branch 'origin/5.13.2' into 5.13Qt Forward Merge Bot2019-10-301-1/+1
| | | |\ | | | | | | | | | | | | | | | Change-Id: Ieb5afc87086758119bcfc8efbe355f5c0a93fc04
| | | | * Fix build: disable the HWRNG in bootstrapped modeThiago Macieira2019-10-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | qmake build fails: qrandom.o: in function `QRandomGenerator::SystemGenerator::generate(unsigned int*, unsigned int*)': /home/tjmaciei/src/qt/qt5/qtbase/src/corelib/global/qrandom.cpp:333: undefined reference to `qRandomCpu(void*, long long)' Fixes: QTBUG-78937 Change-Id: Ib5d667bf77a740c28d2efffd15cb4236f765917c Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
| * | | | Deprecate reverse iteration on QHashLars Knoll2019-11-051-18/+234
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | std::unordered_map only supports forward iteration for good reasons. Align our API with this by deprecating reverse iteration and the operator+/-() for iterators. [ChangeLog][QtCore][QHash] Reverse iteration over QHash is now deprecated. [ChangeLog][Potentially Binary-Incompatible Changes] QHash's iterator category was changed from bidirectional iterator to forward iterator. This may cause trouble if a library uses the iterator category to alter functionality through tag dispatching. This only applies when compiling the library or application with QT_DISABLE_DEPRECATED_BEFORE=0x050F00 and the other with a lower value. Change-Id: I0fb6d017cabdef1bc508e62f76dc2fa73cd3652d Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* | | | | Get rid of QT_STRICT_ITERATORSLars Knoll2019-11-044-54/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The concept was a nice idea to avoid accidental detach() calls in implicitly shared containers, but it conflicts with a C++11 compatible API for them, with signatures for modifying methods taking a const_iterator as argument and returning an iterator (e.g. iterator erase(const_iterator)). Change-Id: Ia33124bedbd260774a0a66f49aedd84e19c9971b Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | | | Get rid of unsharable containersLars Knoll2019-10-3010-135/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The support for unsharable containers has been deprecated since Qt 5.3.0, so let's finally remove support for them. Change-Id: I9be31f55208ae4750e8020b10b6e4ad7e8fb3e0e Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | | | Ensure QListIterator gets defined inside the qtnamespaceLars Knoll2019-10-301-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: I9078893d530836396453c8cc0d2870d77989f076 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | | | Make QList an alias to QVectorLars Knoll2019-10-304-3166/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is almost 100% source compatible with Qt 5. Exceptions are * Stability of references for large or non movable types * taking a PMF for types that are now overloaded with r-value references in QVector * The missing prepend optimization in QVector (that is still planned to come for Qt 6) Change-Id: I96d44553304dd623def9c70d6fea8fa2fb0373b0 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | | | Move QListSpecialMethods over to QVectorLars Knoll2019-10-302-28/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend QVector with special methods for QByteArray and QString, just as QList had them in Qt 5. This also means that QStringList and QByteArrayList are now implemented through a QVector, not a QList anymore. QListIterator<QString> is now slightly source incompatible as QStringList is a QVector, but that will be fixed in a follow-up change when QList<QString> will start mapping to a QVector. Change-Id: I7cfb8a72d4d95b347bbd386892f244b7203b41c2 Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* | | | | Replace Q_ALIGNOF usage in qtbase with C++11 alignof keywordVolker Hilsheimer2019-10-295-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The macro is not documented, so not part of the public Qt API. It is made obsolete by the alignof keyword in C++11. Remove the usage of the macro across qtbase, in particular the workarounds for compilers that didn't support alignof, and that will not be supported in Qt 6. The macro definition is left in place, no need to break existing code. Task-number: QTBUG-76414 Change-Id: I1cfedcd4dd748128696cdfb546d97aae4f98c3da Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
* | | | | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-10-273-0/+26
|\| | | | | | | | | | | | | | | | | | | Change-Id: I182a639748760393f9e6b0724259201588aeaae3
| * | | | Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-10-263-0/+26
| |\| | | | | | | | | | | | | | | | | | Change-Id: I208a36bf1c88c8291baaa5ca8fe8e838bc9d7aea
| | * | | QSet: Document to/from QVector transformation techniquesSamuel Gaist2019-10-243-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change-Id: I2a2ff6332bd6e8ed3d4ba7b4765da0a94a06f133 Fixes: QTBUG-71067 Reviewed-by: Paul Wicking <paul.wicking@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* | | | | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-10-261-31/+20
|\| | | | | | | | | | | | | | | | | | | Change-Id: I379794a01cbf6fb39d94b24cc8c90b1971a212b9
| * | | | Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-10-251-31/+20
| |\| | | | | | | | | | | | | | | | | | Change-Id: Iebedaa967a263854f18cd403ce007d7965f26d2b
| | * | | Merge remote-tracking branch 'origin/5.13' into 5.14Qt Forward Merge Bot2019-10-241-31/+20
| | |\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qstandardpaths_unix.cpp src/corelib/tools/qsharedpointer_impl.h tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp Change-Id: Iae95c5778dc091058f16f6db76f04a0178a9e809
| | | * | Q{Shared,Weak}Pointer: Reduce overload sets in implicit conversionsMilian Wolff2019-10-111-31/+20
| | | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Only allow implicit conversions when the types involved are compatible. That means, only allow construction and copy assignment when the type X* is convertible to type T*. This is done using SFINAE and the std::is_convertible type trait, which makes the previous QSHAREDPOINTER_VERIFY_AUTO_CAST obsolete. This patch fixes compilation when a function is overloaded with Q{Shared,Weak}Pointer of different, incompatible types. Previously, this resulted in a compilation error due to an ambiguous overload. Change-Id: I069d22f3582e69842f14284d4f27827326597ca2 Fixes: QTBUG-75222 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | | Merge remote-tracking branch 'origin/5.15' into devQt Forward Merge Bot2019-10-141-0/+12
|\| | | | | | | | | | | | | | | Change-Id: I129dd579f92cb2592a38ca043472b45cb926ae12
| * | | Merge remote-tracking branch 'origin/5.14' into 5.15Qt Forward Merge Bot2019-10-131-0/+12
| |\| | | | | | | | | | | | | | Change-Id: I9953c1ca16862184c2373027e946c482ce8e6f0e