aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/common
Commit message (Collapse)AuthorAgeFilesLines
...
* Change value encoding scheme to make space for larger pointersUlf Hermann2023-01-121-148/+340
| | | | | | | | | | | | | | | | | | On android and on some other platforms, the upper bits of a pointer are significant. We need to store them in our JS value encoding. Shift the bits around to make this happen. We now can store pointers of up to 57 bits. That's enough for everything we've seen so far. Fixes: QTBUG-101686 Fixes: QTBUG-91150 Pick-to: 6.5 Change-Id: I72e0fe63b27fca94840f82963e4d3936b3581b28 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
* QObjectWrapper: Fix calling attached methods on different objectsUlf Hermann2023-01-021-0/+1
| | | | | | | | | | | | | You can generally store a method in a value and call it on a different object. However, since we've ignored the thisObject basically forever, we cannot just accept it right away. Add an opt-in mechanism via a pragma that allows you to pass (implicitly via context or explicitly via call()) specific thisObjects to QObject methods. Fixes: QTBUG-109585 Pick-to: 6.5 Change-Id: I4c81b8ecf6317af55104ac9ebb62d98862ff24e7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Fix recognition of builtin list typesUlf Hermann2022-12-151-5/+20
| | | | | | | | | | | | | Previously all list types used as arguments or return types for methods had to be looked up via the imports. However, builtin types are not part of the imports at run time. Therefore, recognize list types already early on, when generating the IR. This is the same way we do it for property types and it allows us to easily identify lists of builtins. Pick-to: 6.5 Fixes: QTBUG-109147 Change-Id: I91fa9c8fc99c1e0155cc5db5faddd928ca7fabbc Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qml: silence -Wextra-semiTim Blechmann2022-11-161-2/+2
| | | | | | | | | silence gcc's -Wextra-semi. the private headers are pulled in via the type compiler Pick-to: 6.4 Change-Id: I5291d007c379f522c2dae9d814c4f4cc6a7d118a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Bump QV4_DATA_STRUCTURE_VERSION after dropping CallElementUlf Hermann2022-11-081-1/+1
| | | | | | | | | | All the instruction numbers have changed. Amends commit 872e91612fd83de6dd1193014b5e2a0f5e8c30af. Task-number: QTBUG-106708 Change-Id: Icd448dd8891edb6e9e8ab9bf0234c0ee0126b86f Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Avoid -Wshorten-64-to-32 warnings in a few placesFabian Kosmale2022-10-312-2/+4
| | | | | | | | | | ...by explictily casting to int. Add a few comments explaining why we can get at most INT_MAX many elements, and add Q_ASSERTS to check that the assumptions actually hold. Task-number: QTBUG-105055 Change-Id: I1769318a9c04b51efe45fe0cae9fc0d93cfec45e Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Port to new Q_UNREACHABLE_RETURN()Marc Mutz2022-10-201-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator to convert sequences of Q_UNREACHABLE() + return into Q_UNREACHABLE_RETURN(), newly added to qtbase. 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)); a.k.a qt-use-unreachable-return. subStmt() and nextStmt() are non-standard matchers. There was one false positive, suppressed it with NOLINTNEXTLINE. It's not really a false positiive, 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. Change-Id: I3855b2dc8523db1ea860f72ad9818738162495c6 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add option to enforce function signaturesUlf Hermann2022-10-141-0/+1
| | | | | | | | | | | | | | | | | | | | | By default, the QML engine does not enforce signatures given as type annotations to functions. By passing different types than the function declares, you can get different behavior between the interpreter/JIT and the AOT-compiled code. In addition, in interpreted or JIT'ed mode, we pass all non-primitive value types as references. This means, if you modify them within the called function, the modifications are propagated back to the place where the value was loaded from. Enforcing the signature prevents all of this, at a run time cost. Since we have to coerce all arguments to the desired types, the function call overhead grows. This change introduces a pragma "FunctionSignatureBehavior" which you can set to "Ignored" or "Enforced" to choose one way or the other as universal way of handling type annotations. Fixes: QTBUG-106819 Change-Id: I50e9b2bd6702907da44974cd9e05b48a96bb609e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Track the statement indices together with line numbersUlf Hermann2022-10-131-13/+33
| | | | | | | | | | We will need the statement indices when tracking value type references. New value type references shall only be written back in the same statement they were created in. Task-number: QTBUG-99766 Change-Id: I83f908df034e7da8ba46ccacaa29bd9d78020d20 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Qml: Analyze qsTranslate at compile timeUlf Hermann2022-10-131-2/+2
| | | | | | | | | | We generate translation bindings for all the other translation functions already. We can just as well generate a translation binding for this one, too. Fixes: QTBUG-107536 Change-Id: I851f03c26510b6d450aa78f5d7a1f0142d3a81aa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlTranslation: Use std::nullptr_t rather than std::monostateUlf Hermann2022-10-112-5/+8
| | | | | | | | | | | | Wrapping a std::monostate into a std::variant gives the static analyzer all kinds of headaches. std::nullptr_t should have the same effect without the interesting special cases. Coverity-Id: 401041 Coverity-Id: 401042 Coverity-Id: 401046 Change-Id: I786aefbe0392b5f961c99d7de8bd592bdf591143 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Port from container::count() and length() to size()Marc Mutz2022-10-074-6/+6
| | | | | | | | | | | | | | | | | | | | This is a semantic patch using ClangTidyTransformator as in qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8: auto QtContainerClass = anyOf( expr(hasType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))))).bind(o), 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', with the extended set of container classes recognized. Change-Id: Idb1f75dfe2323bd1d9e8b4d58d54f1b4b80c7ed7 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* V4: Use an enum to categorize functions and rename aotFunctionUlf Hermann2022-09-291-3/+3
| | | | | | | | We want to use the aotFunction member also for typed JavaScript functions. Change-Id: Iad6d12ebed3ad3069832484137ed8e4d9e7a7cf4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Optimize QObject method callsUlf Hermann2022-09-201-6/+15
| | | | | | | | | | | | | | | | | | | | | | So far, for each method call we had to allocate a new QObjectMethod as we didn't have any lookup to cache the methods. Introduce a new lookup for that and use it for all QObject methods. Since QObjectMethod contains a pointer to the concrete QObject the method was retrieved from, some more care has to be taken: If we are going to call the method right away, we don't need the object since we always have a thisObject and any further retrieval of the same method will result in a call again. This enables us to cache the method for any instance of the same class. When storing the method elsewhere, though, we need to hold on to the object since you can defer the call or connect a handler to a signal or similar. For such operations we do need the object. We can still optimize a bit by re-using the method cache we build the first time around. Fixes: QTBUG-95628 Change-Id: I5991180c5e0234cdc179c2b78a43dafc9083e525 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmltc: translation binding supportSami Shalayel2022-08-252-0/+2
| | | | | | | | | | | | | | | | | | | | | | | Implement and test support for translation bindings in qmltc: * qsTr() * QT_TR_NOOP() * qsTrId() * QT_TRID_NOOP() Not compiled by qmltc, but instead interpreted as script bindings: * combinations like qsTr(qsTr()) * qsTranslate() (as in qmlsc) * QT_TRANSLATE_NOOP() (as in qmlsc) Add the *.qm files directly to the resources as qt_add_translations() is not available from qtdeclarative (the cmake function lives in qttools that depends on qtdeclarative). Fixes: QTBUG-104637 Task-Id: QTBUG-105346 Change-Id: Ia9433c2bcef01f3486358d963059d9779c67708c Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Create Translation Bindings without CompiledData::BindingSami Shalayel2022-08-152-0/+194
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To add translation bindings to qmltc, the methods used to create translation bindings need to be adapted to work without QV4::CompiledData::Binding as it is not available from qmltc. Instead, information already available from the QQmlJSScope should be used, along with a newly introduced helper class QQmlTranslation. Details: Add a QQmlTranslation class that represents a call to qsTr, qsTrId etc that knows how to translate itself (without needing any ExecutableCompilationUnit or Binding). It encapsulates the information needed to create a translation binding. ExecutableCompilationUnit::bindingValueAsString refactored so its functionality can be used without Binding. Instead, it uses only the translationId, see ExecutableCompilationUnit::translateFromId and ExecutableCompilationUnit::translateFrom. Refactored QQmlTranslationBinding to work with QQmlTranslation instead of CompiledData::Binding. Same for QQmlCppBinding::createTranslationBindingForBindable, QQmlTranslationPropertyBinding::create and QQmlCppBinding::createTranslationBindingForNonBindable. Changed TranslationBindingInformation to work without CompiledData::Binding, and also removed static unused QString ProxyTranslator::originStringFromInformation( const TranslationBindingInformation &translationBindingInformation) as I could not find out what this origin string is. Same for the translation debugging in qmldb_preview. Added QmltcCodeGenerator::generate_createTranslationBindingOnProperty. Added #if to avoid compilation error for standalone DOM compilation due to the new QQmlTranslation class. Task-number: QTBUG-105345 Change-Id: Iccd94d5cba4eaf63901233451fec48051c855c2a Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qqmltypecompiler: align runtime function table order to qmlcachegenAndrei Golubev2022-07-221-1/+1
| | | | | | | | | | | | | | | | When we write runtime functions to compilation unit at run time, the order of the functions in the unit (often) differs from the order of functions in the unit produced ahead of time by qmlcachegen and friends. Additionally, the order also differs from what qmltc expects (and qmlcompiler library in general) Fix the order by simplifying the procedure of JS code generation when we create the compilation unit at run time: new logic just goes over the objects in the document linearly, instead of relying on bindings (which are known to be out of order w.r.t. AST) Change-Id: I4070b9d061f03c4c76d03120654ad3f30725493a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QtQml: Move idIndex into bitfield union of AliasUlf Hermann2022-06-201-10/+18
| | | | | | | | | | | Since we can now add a member that covers the whole storage, we can clean this up a bit. Change-Id: I707f1f3706d68a073d4b0f4937c352bd3df34335 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Marc Mutz <marc.mutz@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Use SPDX license identifiersLucie Gérard2022-06-1111-418/+22
| | | | | | | | | | | | 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. Pick-to: 6.4 Task-number: QTBUG-67283 Change-Id: I63563bbeb6f60f89d2c99660400dca7fab78a294 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
* QV4::CompiledData: fix GCC 12 -Werror=uninitialized errorsMarc Mutz2022-06-021-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The non-default ctors tried to call m_data.set(), where m_data uninitialized. Says GCC 12: In member function ‘QSpecialIntegerAccessor<S, pos, width, T>& QSpecialIntegerAccessor<S, pos, width, T>::operator=(Type) [with S = QLittleEndianStorageType<unsigned int>; int pos = 0; int width = 5; T = unsigned int]’, inlined from ‘void QSpecialIntegerBitfieldUnion<S, Accessors>::set(typename A::Type) [with A = QSpecialIntegerAccessor<QLittleEndianStorageType<unsigned int>, 0, 5, unsigned int>; S = QLittleEndianStorageType<unsigned int>; Accessors = {QSpecialIntegerAccessor<QLittleEndianStorageType<unsigned int>, 0, 5, unsigned int>, QSpecialIntegerAccessor<QLittleEndianStorageType<unsigned int>, 5, 27, unsigned int>}]’ at qtbase/src/corelib/global/qendian_p.h:214:21, inlined from ‘QV4::CompiledData::RegExp::RegExp(quint32, quint32)’ at qtdeclarative/src/qml/common/qv4compileddata_p.h:187:31, inlined from ‘int QV4::Compiler::JSUnitGenerator::registerRegExp(QQmlJS::AST::RegExpLiteral*)’ at qtdeclarative/src/qml/compiler/qv4compiler.cpp:198:34: qtbase/src/corelib/global/qendian_p.h:179:40: error: ‘<unnamed>.QV4::CompiledData::RegExp::m_data.QSpecialIntegerBitfieldUnion<QLittleEndianStorageType<unsigned int>, QSpecialIntegerAccessor<QLittleEndianStorageType<unsigned int>, 0, 5, unsigned int>, QSpecialIntegerAccessor<QLittleEndianStorageType<unsigned int>, 5, 27, unsigned int> >::storage.QSpecialIntegerStorage<QLittleEndianStorageType<unsigned int> >::val’ is used uninitialized [-Werror=uninitialized] 179 | UnsignedType i = S::fromSpecial(storage->val); | ~~~~~~~~~~~~~~^~~~~~~~~~~~~~ qtdeclarative/src/qml/compiler/qv4compiler.cpp: In member function ‘int QV4::Compiler::JSUnitGenerator::registerRegExp(QQmlJS::AST::RegExpLiteral*)’: qtdeclarative/src/qml/compiler/qv4compiler.cpp:198:90: note: ‘<anonymous>’ declared here 198 | regexps.append(CompiledData::RegExp(flags, registerString(regexp->pattern.toString()))); | ^ Fix by calling the default ctor (which initialized m_data) before calling m_data.set(). Pick-to: 6.3 6.2 5.15 Task-number: QTBUG-103924 Change-Id: I44ff404e5509e24601893e539639f213defdc80d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QML: Add an option to bind components to filesUlf Hermann2022-05-231-0/+1
| | | | | | | | | | | | | | | If a component is bound to a file context, we can be sure that the IDs present in the same file will be accessible to bindings and functions inside the component. We will need this to allow such bindings to be compiled to C++. [ChangeLog][QtQml] You can now bind components to a file scope. This way you can make sure IDs in the file are accessible to the components. Task-number: QTBUG-101012 Task-number: QTBUG-102806 Change-Id: I290a61752b4b02e13f0bb0213ba3f871bdb95260 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QmlCompiler: Detect non-integral values when accessing QQmlListPropertyUlf Hermann2022-05-191-0/+4
| | | | | | | | Pick-to: 6.2 6.3 Fixes: QTBUG-103560 Change-Id: Ifcc73baf7f79e30f6e83ff3e500dd39f95790bfe Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::Property to new special integer bitfieldUlf Hermann2022-05-111-17/+37
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I46f9151536ba09417d117d690d7347bd91c13e75 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::Binding to new special integer bitfieldUlf Hermann2022-05-111-27/+46
| | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I9f8bc5fa45c61f77ee95b055a3d8de001da8f8c5 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QML: Port QV4::CompiledData::Location to new special integer bitfieldUlf Hermann2022-05-111-16/+28
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: If0d6f893f2351a4146ddf125be4079b5e312f308 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::Lookup to new special integer bitfieldUlf Hermann2022-05-111-6/+13
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I8cc6db56642f1cd2d16e80ba5c49ffd7c6fdcd8c Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::RegExp to new special integer bitfieldUlf Hermann2022-05-111-6/+14
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I37be080387bf086d84761b056140cc5a99d161ed Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::Alias to new special integer bitfieldUlf Hermann2022-05-111-9/+66
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I554f9f903a39a83eaf601fd4fd932f685bf343d0 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::Object to new special integer bitfieldUlf Hermann2022-05-111-6/+51
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: Ia57a16313e883a8d4dab15c971181440ed1d2214 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::ParameterType to new special integer bitfieldUlf Hermann2022-05-111-5/+20
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I515aa7a605accc4b45f9dd4918dd6bfb6e116379 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QML: Port QV4::CompiledData::JSClassMember to new special integer bitfieldUlf Hermann2022-05-111-6/+14
| | | | | | | | Pick-to: 5.15 6.2 6.3 Task-number: QTBUG-99545 Change-Id: I0a7d86450011f1664d61db4d78317dafbcfbb8cf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Fix typo and apply some cosmeticsUlf Hermann2022-04-111-1/+1
| | | | | | Change-Id: If51b86e1741b7e9f0e7e4d5f593496bd28cec081 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Make sure all private headers include at least one otherThiago Macieira2022-03-102-4/+4
| | | | | | | | | | See script in qtbase/util/includeprivate for the rules. Since these files are being touched anyway, I also ran the updatecopyright.pl script too. Change-Id: Ib056b47dde3341ef9a52ffff13ef677e471674b6 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
* Avoid spurious dependency on qml_compile_hash_p.hFabian Kosmale2022-02-131-2/+0
| | | | | | | | | | | | The compile hash changes on every commit, so including it in a central header like qv4compileddata_p.h would cause many spurious rebuilds. As we only needed it there for a static assert, we can simply move that check into a source file. Pick-to: 6.2 6.3 Change-Id: I9f24cb3faf5172023b0ece9e6aa07db02638c8be Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Allow custom named value types in QMLUlf Hermann2022-01-251-4/+4
| | | | | | | | | | | | | | | | | | | | | | | You can now add your own, lower-case named, value types to your own module, and use them in QML. Previously the names had been ignored, but now you can actually declare properties using the value types. The QtQuick value types are now handled exactly this way, and their special casing at compile time is removed. [ChangeLog][QML][Important Behavior Changes] You can now add your own value types to QML modules. This works exactly like the registration of object types, just with Q_GADGET instead of QObject/Q_OBJECT. In turn, the QtQuick value types are only available from QtQuick now. Previously you could declare unusable properties of QtQuick value types when only importing QtQml. This is not possible anymore. Task-number: QTBUG-82443 Change-Id: I5b2e867141244531cb13d789678fb7e06a6e41e7 Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* Further tighten checks around QML_COMPILE_HASHUlf Hermann2022-01-201-0/+2
| | | | | | | | | Log the differing hashes in case of a mismatch. Pick-to: 6.2 6.3 Task-number: QTBUG-99608 Change-Id: Id85306d3cfdb08d235c8717b441105c5d0b68cf3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlJs::FixedPoolArray: fix UB (precondition violation) in allocate()Marc Mutz2022-01-031-1/+1
| | | | | | | | | | | | Says ubsan: qqmljsfixedpoolarray_p.h:90:19: runtime error: null pointer passed as argument 2, which is declared to never be null Fix, like in so many other places, by a size check. Pick-to: 6.3 6.2 5.15 Change-Id: I9181d6ecb467c2dc726978ce7f93b35a6bf2f944 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
* QmlCompiler: Fix return type calculationUlf Hermann2021-12-061-2/+4
| | | | | | | | | | We can return void from a function, explicitly or implicitly, and we need to be able to wrap that into a QVariant. In order to explicitly return void, we need the void type to be exposed and understood. Pick-to: 6.2 Change-Id: I513cabb25469b89a85b5d212a6825a037400729d Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Clean up QQmlJS::MemoryPoolUlf Hermann2021-11-221-8/+6
| | | | | | | | There is no reason to derive it from QSharedData, and it shouldn't be copied or moved. Change-Id: If5638b2817295daf2b96a542b70f7d9cabf160d3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Add a Pragma for list assign behaviorUlf Hermann2021-10-131-1/+5
| | | | | | | | | | [ChangeLog][QtQml] You can now specify the list property assignment behavior in QML using the "ListPropertyAssignBehavior" pragma. This is analogous to the macros you can use in C++. Fixes: QTBUG-93642 Change-Id: I9bdcf198031f1e24891f947b0990a3253d29a998 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* SaveableUnitPointer::saveToDisk restores flags incorrectly at cleanupJarkko Koivikko2021-09-171-1/+2
| | | | | | | | | | | | | | | SaveableUnitPointer::saveToDisk function uses XOR to restore flags, which causes the existing flags to be reset instead of restored. This can have major side effects, such as deallocation of StaticData units from static data cache (which should never be freed). Fixes: QTBUG-96275 Pick-to: 6.2 5.15 Change-Id: I09c06f2854fe07a12a2d97290a3e39604a25fd9a Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io> Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
* Upgrade std::is_trivial::value to C++17 std::is_trivial_vIvan Tkachenko2021-08-241-1/+1
| | | | | | | | | Since Qt 6 requires at least C++17, we can finally make use of some of its goodness. Change-Id: I56a318bc0b1b60d1e2b0186f335f8feda7622df4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* When binding signals, run the outer function to get the nested oneUlf Hermann2021-08-171-2/+3
| | | | | | | | | | | | | | | The outer function may perform important tasks like setting up a call context with a "this" member for the nested function. In particular, arrow functions retain their original "this" member, no matter where they are executed later. We can detect this condition while generating the compilation unit. If the outer function is not a simple wrapper that only returns the inner function, execute it when binding a signal. Fixes: QTBUG-95659 Pick-to: 6.2 Change-Id: I7dfef2c78378588e6bfc4bedde7889c7f2ce03ef Reviewed-by: Yuya Nishihara <yuya.nishihara@qt.io> Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
* Avoid UB in qjsnumbercoercion.hUlf Hermann2021-06-161-1/+5
| | | | | | | | | We need to check for NaN before casting a double to an integer. Pick-to: 6.2 Task-number: QTBUG-94068 Change-Id: Ib7bfab5ab2e24af950c8f8d7b32c7d411bd8cb71 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Evaluate type assertions in QMLUlf Hermann2021-05-261-1/+1
| | | | | | | | | | | | | | | | | | Type assertions actually check whether the expression matches the type, and return null if it doesn't. [ChangeLog][QtQml] You can use TypeScript-like type assertions using "as" now. In contrast to TypeScript, QML's type assertions are enforced at runtime. If the type doesn't match, null is returned for object types. Also, type assertions can only cast to object types. There is no way to create a value type or primitive type reference. As value types and primitives cannot be polymorphic, this doesn't matter, though. There are other ways of converting those. Task-number: QTBUG-93662 Change-Id: I00fce3d4ea7a8c6b4631c580eaf6c113ac485813 Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Increment QV4_DATA_STRUCTURE_VERSIONFabian Kosmale2021-04-141-1/+1
| | | | | | | | | The bytecode format has been changed, as two new instructions were added. Amends 5f7ecce23321f499b1b002c32a27c63815535baa. Change-Id: Ie81651a48eec38b014e3bc859cc8ecb0cf8396d0 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmldom: Improve basic infrastructureFawzi Mohamed2021-04-141-0/+13
| | | | | | | | | | | | | | | * introduce function_ref to represent a reference to a function and use it consistently (http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p0792r5.html) * restricted errormessage levels to those of QtMsgType * made path iterate on its segments * made path methods mirror the DomItem methods, so that path construction and access are similar * AttachedInfo to keep the location information * SourceLocation::combine Change-Id: I152c4cc2c601e867f205a4f4b7b3f24884d60ad9 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Ensure that empty tokens in the AST are emptyFawzi Mohamed2021-03-261-0/+30
| | | | | | | | | | | | | | | | Arrow functions introduce a virtual functions and return statements to simplify code generation (arrow function look like normal function definitions), but to have correct firstSourceLocation / lastSourcelocation other tokens were reused. Use an empty SourceLocation at the correct position instead, so code that expects the correct location (for error messages,...) works and code that expects the correct token content (rewriter in QtCreator for example) also works. Introduce helper SourceLocation::startZeroLengthLocation/ endZeroLengthLocation to simplify such code. Change-Id: I1c5df16e1704df2df9b7cbd1a039ce56be3727d3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Consider only default constructed SourceLocation invalidFawzi Mohamed2021-03-261-1/+3
| | | | | | | | | | | | | | | | | | | SourceLocation::isValid consider invalid all SourceLocations with length == 0. This is misleading because we already have several SourceLocations that contain correct information but have zero length like: * In the Ast several places, especially related to the use of Semicolon in the grammar, which might be an automatic semicolon and have length 0, but still be at the correct place, see ReturnStatement and many others. * Parser error messages, which (even worse) set only line/column Note that SourceLocation() == SourceLocation(0,0,0,0) is indeed invalid, as the first location of a file is SourceLocation(0,0,1,1) because both column and line number start at 1. Change-Id: Ib9184f2ee4842e85c505c94ccbbcefb119925492 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Remove qqmlapiversion_p.hFabian Kosmale2021-03-192-57/+0
| | | | | | | | | It is not needed anymore. Change-Id: Ia09c7aa79a0525ca59adc729f4d7f4c69d37e8c9 Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io> Reviewed-by: Mitch Curtis <mitch.curtis@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>