Commit Graph

289 Commits

Author SHA1 Message Date
Ulf Hermann 4634b6bf54 QmlCompiler: Disallow reading from values affected by side effects
Instead of accepting the inconsistency between interpreter and compiled
code here, we can just detect whether a value can be affected by side
effects and refrain from reading it then. Since you can always
explicitly reload a value that may have been changed, the resulting
compile warnings are easily worked around in user code. Refactoring user
code this way also makes it much clearer what is actually going on.

Pick-to: 6.5
Task-number: QTBUG-109221
Change-Id: Ica832e39838ef732b0d181364630737fd7709b74
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-04 16:44:44 +02:00
Ulf Hermann 44ca1085d6 QML: Fix call frame conversion for QVariant return types
The function may return a QVariant in place of the actual type because
it cannot express the actual type as-is. This case needs special care
because QMetaType::convert() doesn't know what to do with it.

Pick-to: 6.5
Fixes: QTBUG-112837
Change-Id: Ibf93a28aa6a60d49c5ab63fa7eed5f5a8e58e163
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-04 11:48:09 +02:00
Ulf Hermann b8814dfb36 QmlCompiler: Do not crash when converting number literals to enums
Amends commit 2a21efb5f7.

Change-Id: Id7d739b58c723eed9f165951b51ee2e5e55d7fe2
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-05-04 11:48:09 +02:00
Ulf Hermann 1abfb04fae QmlCompiler: Do not stop parsing on top-level Component elements
This just creates an inconsistent state where some of the document has
been parsed and some hasn't. The only thing we actually need is the log
message. Also, fix the warning message.

Amends commit 169f0f7166.

Pick-to: 6.5
Fixes: QTBUG-112897
Change-Id: Ie8486909f9bea9ee1b87f2857f7b77fb7cc561e8
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-05-03 14:38:52 +02:00
Ulf Hermann 25b259270d tst_qmlcppcodegen: Sort QML files again
Keeping them sorted reduces the chance of collisions and makes it easier
to find related ones.

Change-Id: Ie05cbfefa5805cd27ec91e566dd922107c70d8e2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-02 19:29:25 +02:00
Ulf Hermann 46cc70e2aa QmlCompiler: Relax shadowing check
If we detect a property or method as potentially shadowed, we don't have
to abandon all hope. We can still retrieve it as untyped var. Since
there are a number of things we can do with untyped var, this may still
be useful.

In the same sense, we need to treat function calls as untyped when the
function in question can be shadowed. Calling functions with var
arguments and return types leads to some more interesting situations in
the call frame setup, so we fix that, too.

Task-number: QTBUG-112480
Change-Id: I238d1cf04951f390c73e14ed9e299f2aa72b68cb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-02 19:29:25 +02:00
Ulf Hermann e846864151 QmlCompiler: Inline some array methods
So far we can only deal with methods that don't change the source array
and don't use iterators or functions as parameters. We also omit
concat() for now. However, indexOf(), lastIndexOf(), includes(),
join(), slice() and toString() are possible already now.

Task-number: QTBUG-112722
Change-Id: Id19c74e8ad25af876bc954c040c767823b7e3259
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-04-28 21:24:17 +02:00
Ulf Hermann f10630aa03 QmlCompiler: Use actual type of enums, rather than int
Now that the type is available from qmltypes we can just use it.

Task-number: QTBUG-112180
Change-Id: I315372da0925f19c209f676226f450863b0d3ea5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-04-26 10:57:27 +02:00
Ulf Hermann 365b781599 QmlCompiler: Implement ConvertThisToObject and basic DTZ
We know that 'this' is a QObject* since the metatypes stack frame
mandates it. Whenever you pass 'this' to anything it's loaded from the
special 'This' stack slot which then triggers a DTZ check. A DTZ check
is a noop if we can prove that the type is statically known, though.

In QmlCompiler, if we have a valid register content, then the register
has been set in all code paths that lead to the instruction in question.

Fixes: QTBUG-111439
Change-Id: I81d1cd140eea63f85628c3bef3a8f6db0a12096d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-04-25 16:53:00 +02:00
Ulf Hermann 653a6ff82a QmlCompiler: Recognize QStringList and QVariantList as special lists
They are equal to QList<QString> and QList<QVariant>, respectively. We
cannot express this fact in qmltypes, but since those are builtin, we
can just hardcode it.

Task-number: QTBUG-112227
Change-Id: Iebeb5f6a5350d1c7184b1d9e6a38647e048c3806
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-04-24 22:22:14 +02:00
Ulf Hermann fa259ed4ff QmlCompiler: Allow conversion from QQmlListProperty to QList
In the happy case this just retrieves the internal QList from the list
property. In the sad case it produces a deep copy. That's not worse than
what the interpreter does, though.

Fixes: QTBUG-112227
Change-Id: I8b2b0ac74c90b6dcee876e83a64502756733c1c5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-04-24 22:22:14 +02:00
Ulf Hermann 7c2e31c34f QmlCompiler: Don't crash on bad list type in signature
Pick-to: 6.5
Change-Id: I2c4a4ffa810258134a29b87aff46e8eb544b6a55
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-04-19 20:01:09 +02:00
Ulf Hermann 1ceaeab982 QmlCompiler: Don't crash when checking for enum problems
When checking for CallProperty we want the call base, not the
accumulator.

Pick-to: 6.5
Change-Id: I24ac066dd440bde459e20b3cf962af04ca531629
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-04-19 20:01:09 +02:00
Ulf Hermann b3281f123e Fix content pointer check for QObject*
It can actually be null rather than undefined. We need to generate a
separate check for that and output the correct error messages.

Amends commit 05f56d7c78

Change-Id: Ia795e31805181640cd5be19359af51067d3fc8d6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-04-19 09:30:58 +02:00
Ulf Hermann f27cb5e3c1 QmlCompiler: Merge bool and any pointer type into the pointer type
A pointer type can hold bool as either nullptr or some value. We don't
need to produce a QVariant for that.

Change-Id: I368c3fa703d08ff396a5b4702ba7d1f2614b1467
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-04-15 20:14:42 +02:00
Ulf Hermann 03ff348b49 QmlCompiler: Support more integer types
This adds support for 8- and 16-bit signed and unsigned integer types.
The test exposes that the engine fails to correctly convert out of range
values when assigning to a 32-bit int property. Fix that as drive-by.

Fixes: QTBUG-101634
Change-Id: I0a4177f49ffc062a1f444e30424e94c1f293e70c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-03-30 15:46:55 +02:00
Ulf Hermann 55cb484934 QmlCompiler: Do not generate invalid code on generate_As
Pick-to: 6.5 6.5.0 6.2
Task-number: QTBUG-111986
Change-Id: Ib6e7179c20e6c7a4d6fc3a1a17eac550d2bbfa56
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-03-17 20:57:14 +01:00
Ulf Hermann ec410555ad QmlCompiler: Allow coercing anything to bool
JavaScript can coerce anything to bool, so should we.

Change-Id: Id560e4c1dc10b5432c0cedf3110ad3377bbc5f59
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-03-10 23:42:49 +01:00
Ulf Hermann 2a21efb5f7 QmlCompiler: Use value type ctors
This allows us to do the relevant conversions in a more civilized way,
dropping the outputVariantConversion() method. The latter is brittle
because you have to manually add it to each instruction, and it uses
QMetaType::convert() which is actually not guaranteed to give the same
results as a QML type coercion.

Task-number: QTBUG-94807
Change-Id: I4d6d05a60beb3b4dfc3da6f0142de25667510904
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-03-09 21:36:30 +01:00
Ulf Hermann 05f56d7c78 QML: Allow as-casting to value types
If the "Addressable" option to ValueTypeBehavior is set, you can use the
"as" operator to cast a previously unknown type into either undefined
or the given type. We can use this in qmlcachegen to generate efficient
code for further operations on the same type.

In the generated C++ it in fact only works for GetLookup because:
a, We generally don't do SetLookup on value types, yet.
b, We generally don't call methods on value types, yet.
c, We cannot store a union of undefined and a sequence type, yet.

However, getting properties of value types is the most important
application of the new casts so this is well worth it.

As a side effect we can also look up things in potentially undefined
results of other operations now. For example list lookups.

Task-number: QTBUG-94807
Change-Id: Ifdf34f1f3f67b7a0a8953b9ed0e947b74638a28c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-03-03 12:02:00 +01:00
Ulf Hermann 35152b432e QML: Add an "Addressable" value to ValueTypeBehavior
Task-number: QTBUG-94807
Change-Id: I8c78faa99fc4c4b2ffd8c89f1037fc7569212c73
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-03-02 17:54:30 +01:00
Ulf Hermann fc1d258069 QmlCompiler: Improve method overload selection
If we have an exact match we should definitely use that.

Change-Id: I2846ecf6f9963a978b84b70fbe18acdfe6eb45e6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-03-02 13:17:47 +01:00
Ulf Hermann 8cbb30a650 QtQml: Always throw when requesting an enum from an invalid singleton
The interpreter does this and so should the enum lookup adapter for
generated C++ code.

Pick-to: 6.5 6.4 6.2
Fixes: QTBUG-109816
Change-Id: I576480c3ca808743ddc0ceaf2f0bd8a1de776a41
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-03-01 11:56:19 +01:00
Olivier De Cannière 98849309a2 QmlCompiler: Implement multi-argument Math.{min,max}()
This patch extends the logic for the 2-argument Math.min() and
Math.max() functions by reutilizing the same logic to compare two
elements and evaluate all arguments with the current max or min.

Fixes: QTBUG-108741
Change-Id: I993a26a1d44d66226c751272dfc2dc63330d115d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-02-23 09:51:22 +01:00
Olivier De Cannière a142873d1c QmlCompiler: Implement get lookup of variantMap properties
This patch adds support for get lookups of QVariantMap properties.
Setting or modifying is not supported and will reject.

Also, QQmlJSRegisterContent::JavaScriptObjectProperty was
renamed to QQmlJSRegisterContent::GenericObjectProperty

Tests were added to TestQmllint::cleanQmlCode() and
tst_QmlCppCodegen::variantMapLookup().

Pick-to: 6.5
Fixes: QTBUG-105545
Change-Id: I653ee4e7de1fb1514e1e563a92cfc28633268a7e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-02-22 16:21:09 +01:00
Amir Masoud Abdol 8f7080fd09 Replace AUTO_RESOURCE_PREFIX with Qt CMake Policy in examples, tests
Every instance of AUTO_RESOURCE_PREFIX has been replaced by either
qt_standard_project_setup(REQUIRES 6.5) or with
qt_policy(SET QTP0001 NEW), mainly in tests.

In addition, I added a warning message for the case where
AUTO_RESOURCE_PREFIX is used.

Pick-to: 6.5
Task-number: QTBUG-96233
Change-Id: I323a15e9d0bb5fe6ba649365314af9fc2ad67bda
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-02-21 19:45:44 +01:00
Ulf Hermann b9834e0ee9 QmlCompiler: Fix coercion of undefined to float and double
It should result in NaN, not in 0. The typedArray() test exposes that
ExecutionEngine::toVariant() also gets this wrong. Fix that, too.

[ChangeLog][QtQml][Important Behavior Changes] Converting a JavaScript
value to a double or float, for example by inserting it into a typed
array, now assumes JavaScript type coercion semantics. In particular,
converting a value that is not actually a number now results in NaN
where it previously sometimes resulted in 0.

Pick-to: 6.5 6.4 6.2
Fixes: QTBUG-111179
Change-Id: If24444ae9014c8972761c565a6920f06699e485c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-02-21 12:13:59 +01:00
Semih Yavuz 95228f0e66 qmlsc: Support equality operations for QUrl
Task-number: QTBUG-110983
Pick-to: 6.5
Change-Id: I9a664178c91bfa2962e2a5a3bf4bfa174a74a9d0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-02-16 11:17:28 +01:00
Ulf Hermann 82cda71298 Controls: Use PlatformDialogHelper for enums in DialogButtonBox
Since we're already using 3 of the 4 enums in PlatformDialogHelper, we
can just as well declare PlatformDialogHelper as extended namespace and
avoid all the fiddling with Q_ENUMS and QFLAGS.

As an additional upside, we get code using those enums to compile to
C++ this way.

Pick-to: 6.5
Fixes: QTBUG-110933
Change-Id: I60bfc15c94133be368fa98ee1b3a0ab7a2bc53ef
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2023-02-15 14:04:44 +01:00
Semih Yavuz 66bc001968 qmlcachegen: fix nonstrict equality code generation
We should generate type checking code for only strict comparison
of var against null/undefined types or vice versa cases. The non-
strict comparison should be handled elsewhere. Removed pragma Strict to
allow to add warning emitting tests of non-strict comparison.

This amends 6a816a9e0d

Pick-to: 6.5
Fixes: QTBUG-110769
Change-Id: I7f9a457e71a621a005f377216e841bec01667454
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-01-31 19:12:30 +01:00
Semih Yavuz db71a35b1e qmlcachegen: Improve QObject comparison code generation test
The code generated for QObject comparisons holds for both weak and
strong comparisons. Improve tst_qmlcppcodegen by adding missing weak
comparison tests.

Amends afc7928d1a.

Pick-to: 6.5
Change-Id: Ib6176a39b329e792b81b3d8e8a288dcea074320b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-01-31 19:12:21 +01:00
Ulf Hermann ddba87612d QML: Turn singleton/type mismatch into a run time type error
There are many ways to "hide" the qmldir from the engine at run time,
which turns singletons into regular types. While all of this is invalid,
we should not assert on it, but rather produce a legible warning.

Furthermore, sharpen the importing of extra modules from qrc as implicit
imports. We should really only import modules the file in question can
ever be part of. Otherwise we needlessly produce the above situation and
hide legitimate warning messages.

Amends commit 7517c1b3ae.

Now we need to teach our tools about the default import paths in the
resorurce file system. They cannot guess any type they may find in any
resource file anymore.

Pick-to: 6.5
Task-number: QTBUG-106929
Change-Id: Ic8c02396d10830a7f461e8a81649bb8c9a1add1f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-01-27 10:42:06 +01:00
Ulf Hermann 5f3b8bd08c QML: Allow more conversions between different lists
You should be able to assign any list of QObjects to any other list of
QObjects.

Pick-to: 6.5
Fixes: QTBUG-108155
Change-Id: I6ddf0b49f7248ad56cc9560d217f3ea316c648a8
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-01-26 11:42:33 +01:00
Ulf Hermann 6d181fc043 QML: Allow converting any object list to QQmlListProperty
We can use QSequentialIterable for this.

Pick-to: 6.5
Fixes: QTBUG-110438
Change-Id: I7e82d0f089c9bb9eab46be46dedc2db3726e64b0
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-01-25 17:08:37 +00:00
Ulf Hermann 518509297f qmltyperegistrar: Strip '*' from list value types
We do this for function return types, property types, and function
argument types already. Formally, we would have to store some
"isPointer" somewhere, but considering that we never read it anyway,
let's not go there.

This allows the compilers to recognize lists of QObject-derived types as
proper lists. This way we can generate better code for moving them
around or getting their length.

Pick-to: 6.5
Task-number: QTBUG-110438
Change-Id: I35e0fc21d574afc18799e9c3cef402f05b60a3ed
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2023-01-25 18:08:36 +01:00
Fabian Kosmale aa551eebb5 tst_qmlcppcodegen: Add QML dependency for Android
qmlimportscanner is rather limited in how it works,
and does not pick up the Qt.labs.folderlistmodel
dependency for Dialogs.

Pick-to: 6.5
Fixes: QTBUG-103044
Change-Id: I778f5c8981f1a2603bc3a5d2fd249a83de6c9bd8
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-01-25 17:08:36 +00:00
Ulf Hermann c9b8b06117 QmlCompiler: Wrap sequences with unknown elemnts in QVariantList
Otherwise we later try to perform value type lookups on them. That won't
work.

Pick-to: 6.5
Task-number: QTBUG-110438
Change-Id: I1690a3375841ba5a1ff1a471a7f88bd2023ab4c4
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-23 22:27:38 +01:00
Ulf Hermann ec58c0ddb7 QML: Add a pragma for value type behavior
Unfortunately value types behave differently when compiled to C++.
Document the difference and introduce a pragma to make them behave one
way or the other.

Pick-to: 6.5
Fixes: QTBUG-109221
Change-Id: Ib2685153c0b4ae209bafbea7a01229377fdb47dd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-20 20:39:11 +01:00
Ulf Hermann bda7b2a444 QmlCompiler: Handle various date and time conversions correctly
We can coerce QDateTime, QDate and QTime into each other because they
would all be represented by a Date object in JavaScript. Furthermore we
can coerce them all to QString. Technically, we could also coerce
strings to all of them, but we don't want to because that is terrible.

Fixes: QTBUG-109380
Change-Id: I176bfb5b715a6a6750cb5918c44261fa23fb8832
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>
2023-01-17 21:58:32 +01:00
Ulf Hermann e070b5aa39 Allow extraction of V4 values from QJSPrimitiveValue
Since we can produce QJSPrimitiveValue in metaTypeFromJS, we should also
handle the other direction.

Fixes: QTBUG-109867
Pick-to: 6.5
Change-Id: I2c7598d19eba3e78d071ca3eceb32deda4d0ead8
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-01-16 23:03:57 +00:00
Semih Yavuz afc7928d1a QmlCachegen: Equality comparison ability to QObject *
We should be able to compare QObject * with QObject * or a
nullptr.

Pick-to: 6.5
Fixes: QTBUG-109377
Change-Id: I0e9d6fdc89cbb471774d6382316dfb4813310e1d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-01-10 15:09:23 +03:00
Semih Yavuz 6a816a9e0d QmlCachegen: Equality comparison ability to var and void/null types
The code generator currently rejects any comparisons other than
primitive types. Add comparison capability for var types against
null or undefined types and vice versa. To achieve this, we generate
code that fetches the contained object within the variant and
comparison is done depending on the stored type.

Ideally, we also need to add comparison capability for QObject *, that will be handled with QTBUG-109377.

Pick-to: 6.5
Fixes: QTBUG-108632
Change-Id: Ib15450d7922f6025c78def5cc548c74827ad740f
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-01-06 17:28:31 +00:00
Ulf Hermann 35e2bb0906 QmlCompiler: Test that infinities cleanly cast to int
Task-number: QTBUG-108820
Change-Id: I984f6f35ffd32ca9adae31e56010d10c683e5615
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2022-12-23 09:02:24 +01:00
Ulf Hermann b13e22f274 QmlCompiler: Fix wrapping of numbers in QJSPrimitiveValue
We need to explicitly cast to double if we are wrapping a number type
that's not natively accepted by the ctors.

As a side effect, correctly run conversions from generic QVariant to
QJSPrimitiveValue through the engine now. For that we need another
clause in metaTypeFromJS().

Since we are calling methods that return list types in the test, we need
to add another clause that converts JS arrays to list types. Otherwise
we cannot run that test in interpreted mode.

Pick-to: 6.5 6.2 6.4 6.4.2
Task-number: QTBUG-109111
Change-Id: I87f7aafd24371d2c1ffe85569e1f2cd3a1979742
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-12-15 17:47:11 +01:00
Ulf Hermann 07d2a80d01 QmlCompiler: Mark StoreElement on JS values has having side effects
A StoreElement on a JS value can do pretty much anything you can
imagine, after all.

Pick-to: 6.5 6.4 6.4.2
Fixes: QTBUG-109196
Change-Id: Ic638d94b55e6340eb9fe56abc663a6f0f2277f5e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-12-15 14:03:55 +01:00
Fabian Kosmale aa4a1e96b8 QQmlJSCodeGenerator: fix nullptr dereference
If we try to lookup the length of a generic QVariant, we fail, and so
far crashed. We should ideally detect that we are dealing with an array
(and thus length is a known, available property), but for now simply
reject compilation to C++.

Pick-to: 6.4
Fixes: QTBUG-109164
Change-Id: I9d4149ac09a351754d012dbc829774413d6b32eb
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2022-12-12 15:33:18 +01:00
Ulf Hermann ce005eae58 QML: Unify postprocessing of imports
We want to always import dependencies, always import qualified scripts,
and always try to load C++-based types from the binary. Furthermore,
directory imports should be imported with their qmldir URI where
possible, so that we can find them when loading local C++-based types.

Fixes: QTBUG-109109
Change-Id: I58f08f479623a886c802035b41f5f604338468b5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-12-07 16:48:35 +01:00
Ulf Hermann a354d91b88 QmlCompiler: Ignore cloned signals when analyzing signal handlers
We obviously want to see the defaulted parameters when generating the
handlers.

Fixes: QTBUG-108762
Change-Id: I33a52bac305238467d45650bf8a2ad59d40e366f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-12-07 13:50:01 +01:00
Semih Yavuz 9793c663cc Fix comparison AOT-lookup and intended type in value types
We currently force the lookup metatype to be exactly the same data type
with the caller's. As a result, the conversion from enum to integral
data type is not recognized. Relax this comparison by using
isTypeCompatible helper.

Pick-to: 6.4
Fixes: QTBUG-109007
Change-Id: I188dc3e6c1fd7100e9ed5c4ba5d0c90d85d79be4
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-12-05 17:39:24 +01:00
Ulf Hermann 8bc748e7e5 QmlCompiler: Fix various kinds of enum lookup
* If we got an object type exposed as namespace, we still need to add
  the "*" to get its augmentedInternalName(). Otherwise we cannot get
  its metaobject, needed to look up enums.
* Enums cannot be shadowed. The shadow check will produce garbage if we
  try to check because an enum lookup also does not use the accumulator,
  which then contains some artifact from a previous operation.
* If we find a property lookup on a plain QMetaObject* we have to
  immediately return in order to not confuse it with attached
  properties.

Pick-to: 6.4 6.2
Fixes: QTBUG-109048
Change-Id: If9e3b4806e4d773de9cf48f1b3750b684a8c8f69
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-12-02 13:35:42 +01:00
Ulf Hermann 43ef237f99 qmltyperegistrar: Generate accessSemantics="none" for foreign namespaces
If the local type is a namespace, the resulting type can only be a
namespace, too, no matter what kind of tag the foreign one has.

Furthermore, we can re-use types with other QML_* tags this way.

Task-number: QTBUG-108883
Change-Id: Ib2ae08d5b081b8faa35124314f97d406d7b4f76f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-29 12:32:27 +01:00
Ulf Hermann 6e640a0218 QmlCompiler: Store imported types in a QList
The same type can be exported multiple times with different attributes,
even in the same module.

This requires us to fix directory imports as qmllint otherwise complains
about SegFault.bad.qml and SegFault.qml being the same type (which they
obviously aren't).

Task-number: QTCREATORBUG-27590
Change-Id: I295d927b9a07acbb715055a6883ac44b50129c2d
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-11-25 00:04:02 +01:00
Ulf Hermann ed47bff411 QmlCompiler: Implement console logging methods
We provide semi-private functions in the AOT context for this. Since we
cannot know the complete run time type of the potential logging category
at compile time, we have to check any first argument that might be one
separately.

Fixes: QTBUG-107175
Change-Id: I46a8922b1c5c16d2b450b8728d650d31dfd867e3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-23 10:27:55 +01:00
Ulf Hermann bce216d5c0 QmlCompiler: Fix comparison of null and undefined
Those are not stored. If we compare null to null or undefined to
undefined, we do not have to generate a comparison at all. the result is
statically known.

Pick-to: 6.4
Fixes: QTBUG-108634
Change-Id: I6a5323c2e0c023838609aec90d7ecc15b885dc08
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-23 10:27:48 +01:00
Ulf Hermann df01095a66 QmlCompiler: Don't crash on CallWithSpread
When preparing for such a call, the byte code loads an "empty" constant.
This has to be represented in the type system so that we don't hit the
assert at the end of the instruction.

Pick-to: 6.4 6.2
Task-number: QTBUG-108441
Change-Id: I66220bfae3d3a4b8e9600d84d4cfc43ac858b77e
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-22 12:32:23 +01:00
Sami Shalayel d9d2477464 Remove signal index mismatch in aot-compiled code
There are multiple types of signal indexes, one of them
belongs to QMetaMethod::signalIndex and another one to
QObjectPrivate::signalIndex.

Stop mixing them up in aot-compiled code when capturing
properties as this leads to weird and hard to debug bugs.

Add a smaller version of the drag and drop example as test
to make sure that the bug does not appear again, without any
visual elements.

Fixes: QTBUG-104047
Fixes: QTBUG-104716
Pick-to: 6.4 6.2
Change-Id: I4f64ba237e824ff0ba1624c29ddcf5371d03d69e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-15 11:52:45 +01:00
Ulf Hermann 1d3d7437ba QML: Fix the most blatant TDZ violations
When reading a let or const register before its declaration we can be
sure this is invalid.

Task-number: QTBUG-108362
Fixes: QTBUG-77428
Change-Id: I7e8f8b46079860f00c051c1a91f773dc8cdd5595
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-14 10:19:08 +01:00
Ulf Hermann 259aec7cb4 QmlCompiler: Ignore InitializeDeadTemporalZone instruction
We don't discern between empty and undefined values in the compiler.

Fixes: QTBUG-104192
Change-Id: Ida06386433ef9e8f9a7cba4bec99ba8e77edc324
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-11 12:07:42 +01:00
Ulf Hermann 91c6d45559 QmlCompiler: Allow lists as arguments to methods
Since lists are allowed as property types, you should be able to pass
them as arguments to methods, too. For now we only handle QML-defined
methods, implemented by adding JavaScript functions to your QML
elements. The usual type coercion rules apply if you pass JavaScript
arrays to such methods. That is, it usually works.

We now resolve properties with the "list" flag to their actual types
(QQmlListProperty or QList) already when populating the QQmlJSScope, and
store the list types as members of QQmlJSScope rather than as a special
map in QQmlJSTypeResolver. This allows us to do the same to lists passed
as arguments and simplifies some of the type analysis.

Fixes: QTBUG-107171
Change-Id: Idf71ccdc1d59f472c17084a36b5d7879c4d959c0
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-11-10 15:00:11 +01:00
Ulf Hermann de2d7cba76 Add option to enforce function signatures
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>
2022-10-14 16:36:36 +02:00
Ulf Hermann 1a0c4094e0 QmlCompiler: Properly check contained type for enums
In case of an enum the actual contained type is the one the enum
dictates. This brings registerContains() in line with containedType()
and makes it possible to match previously discovered types on subsequent
passes of the type propagator. Therefore, it avoids infinite loops where
the same types would be tracked over and over.

Pick-to: 6.4
Fixes: QTBUG-107176
Fixes: QTBUG-107542
Change-Id: I4b8d66b157d0ec0ece4ca345cb99a630b8898a1b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-10-12 20:43:34 +02:00
Marc Mutz 958cd3ee10 Port from container::count() and length() to size()
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>
2022-10-07 23:38:48 +02:00
Ulf Hermann 1e712c95ce QmlCompiler: Do not crash on version-mismatched property access
If we cannot access a property due to a version mismatch, that's not an
unqualified access.

Pick-to: 6.4
Fixes: QTBUG-107080
Change-Id: I1780b171928df437a2121601f1aac829dbe1e994
Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-10-06 20:37:53 +02:00
Lucie Gérard 1b9808737a Change the license of all CMakeLists.txt and *.cmake files to BSD
Task-number: QTBUG-105718
Change-Id: Id89ed14990804a5024183e75382cc539d4293da1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-09-07 17:01:30 +02:00
Ulf Hermann 0a8fe228f6 QmlCompiler: Prevent lookup of value type where we need an object type
With a particular nefarious combination of Q_GADGET and inheritance from
QObject you can make QmlCompiler believe a type is a value type even
though it is actually an object type. We never want to touch such a
thing.

There was a safe guard against this when looking up the type from the
scope, but by putting it in a type namespace you could circumvent it.
Refactor the code to apply to both cases the same way.

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-104556
Fixes: QTBUG-105608
Change-Id: I8a690e2b6f78fcaba0911a93504cde0d2c7dde0d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-08-30 18:53:01 +02:00
Ulf Hermann f4577447a1 QmlCompiler: Implement remaining operators
Some of the math operators were still missing. Add them and test them
all.

Since the "runInterpreted()" test function takes too long now, split the
qmlcppcodegen test in two: One that runs in compiled mode and one that
runs in interpreted mode.

Fixes: QTBUG-105188
Change-Id: I4b641d5e51b5a7e2a9254be40f257d7b249deb13
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-08-29 13:21:06 +02:00
Ulf Hermann b184d02648 QmlCompiler: Allow any conversion possible via QJSPrimitiveValue
All of those are legal in ECMAScript, and so we need to support them in
script bindings. As we have stricter rules for literal bindings, add an
extra method there to check for what QQmlPropertyValidator does.

Pick-to: 6.4
Fixes: QTBUG-105252
Task-number: QTBUG-105188
Change-Id: I0621b2c3aa196414f669873e93670557284a8bca
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-08-03 08:32:50 +02:00
Ulf Hermann 6ea2a1cdb7 QQmlListAccessor: Accept QQmlListProperty
So far we have only accepted QQmlListReference. However, we can also
pass a QQmlListProperty around as value.

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-105137
Change-Id: I7d4cd3048b62594298f91013c4cda5ec864a28df
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-07-26 21:17:28 +02:00
Ulf Hermann 1969a10821 QmlCompiler: Support conversions between QString and QByteArray
Pick-to: 6.4
Fixes: QTBUG-104702
Change-Id: I80d3a28e17751d440ec4bea4c7be0d09c935fa19
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-22 21:30:12 +02:00
Ulf Hermann e97f8cabc8 QmlCompiler: Implement Math.pow()
Also, add missing positive infinity to test data.

Pick-to: 6.4
Fixes: QTBUG-104745
Change-Id: I958aca672cca8cc83c540ed3ea75b08e70eb90fd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-21 13:19:04 +02:00
Ulf Hermann e19328fb0f QmlCompiler: Allow storeNameSloppy to reset a property
We should not convert from undefined on storeNameSloppy. The reset is
intentional.

Task-number: QTBUG-104508
Change-Id: Iede88fe6331dd173c9e8ea0ec4200df2b8bd30eb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-11 13:37:26 +02:00
Lucie Gérard 5a7b716474 Add license headers to cmake files
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: I72c89a98c42bbc9234d8495e9e503bec81d11037
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-07-08 10:41:06 +02:00
Ulf Hermann 38fdf2717d QmlCompiler: Handle trivial signal handler constructions
If the signal handler does nothing but return a closure, we have to
compile the closure using the same signature as the outer signal
handler.

In order for this to work, we also have to detect unresolved argument
types for signal handlers. Those are just as bad as unresolved argument
types for other functions.

Fixes: QTBUG-101531
Change-Id: Idb5b3994809d91a4b4ce936282685435eb75e670
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-07 19:33:39 +02:00
Ulf Hermann 3f3e961a5a QmlCompiler: Allow wrapping enums into int
This is what we do internally in the QML engine.

Pick-to: 6.4
Fixes: QTBUG-104683
Change-Id: I2f8712cb2cdc56b6c483500627fd8a218edbad81
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-07 19:33:27 +02:00
Ulf Hermann 8dc33d3672 QmlCompiler: Don't crash on unknown list value types
Pick-to: 6.4
Fixes: QTBUG-104743
Change-Id: I551b21498bb746acf05be525dbcb72a74f816c04
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-06 21:28:05 +02:00
Ulf Hermann af335a89bd QmlCompiler: Initialize registers with undefined where necessary
If we read the initial state of a register, we need to make sure it
actually exists at that point. Uninitialized variables are implicitly
undefined in JavaScript.

Pick-to: 6.4
Task-number: QTBUG-104687
Change-Id: Ide4fe429b10ec28dcf267e7d34c6316355b16baa
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-05 19:50:28 +02:00
Ulf Hermann 7d36ec0bd9 QmlCompiler: Don't push type conversions back into the engine
In many cases we can generate better code for type conversions.
Furthermore, the engine only does QMetaType::convert(). This misses a
lot of conversions we do in other places.

Pick-to: 6.4
Change-Id: I1526ec327d189420885f6a7385f6cc1c2c94b19e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-05 19:50:24 +02:00
Ulf Hermann 4639607036 QmlCompiler: Really fix writing into argument values
Arguments are now treated as registers "written" at the beginning of
the first basic block. By modeling them this way, we can avoid all the
complicated logic on whether to use a local or the arguments array when
accessing any particular one of them. Furthermore, we can detect whether
they are overwritten or not. If they are not overwritten, we can
initialize them as a const reference into the arguments array. This way
we save a copy.

Treating the arguments as generic registers causes the basic blocks pass
to aggressively adjust their types, pushing some conversions back into
the QML engine. This is good. Unused arguments become void, for example,
and don't have to be passed at all. However, we also need a special case
for QJSPrimitiveValue arguments now.

Pick-to: 6.4
Fixes: QTBUG-104462
Change-Id: I994bea0929bd508aa41db58dee4a7f12cd20f053
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2022-07-05 19:50:19 +02:00
Ulf Hermann 5e4a1738b0 QmlCompiler: Fix register propagation in basic blocks pass
a, We were recording too many jump origins and targets. That messed up
   the basic blocks ordering logic.
b, In the presence of backward jumps, we need to revisit earlier basic
   blocks if additional writes are discovered. Otherwise the type
   adjustment will optimize "dead" type conversions out.

Pick-to: 6.4
Fixes: QTBUG-104665
Change-Id: I7219f85625761817ae4f63582d80d247a85df73b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-07-05 19:50:15 +02:00
Ulf Hermann 0e3d42c840 QmlCompiler: Don't generate invalid code for storing undefined
We don't actually have to store the retrieved value if it's not
storable.

Pick-to: 6.4
Fixes: QTBUG-104508
Change-Id: Ib091eabf4f4034a577b94e0d5761c5307815599e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-29 13:26:07 +02:00
Ulf Hermann 7230508c3b QmlCompiler: Add missing parentheses to in-place arithmetic operations
Pick-to: 6.4
Fixes: QTBUG-104512
Change-Id: I3d592eeda5cefd9e9805b1811b37bebec5d6fc9c
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-28 01:52:43 +02:00
Ulf Hermann a864561468 QmlCompiler: Inline String.arg() into generated code
This way we can compile common translation expressions with .arg(a).

Task-number: QTBUG-101387
Change-Id: I89cdef48b63886684569c5b587ea69c937085b62
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-24 22:17:17 +02:00
Ulf Hermann 23fdccf7f3 QmlCompiler: Inline translation methods
We hardcode them into QQmlJSTypePropagator and QQmlJSCodegenerator for
now. This is OK for builtins.

Task-number: QTBUG-101387
Change-Id: Ifab46083b3a782f009859ce969c283d5bb2b4e8b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-24 14:47:58 +02:00
Ulf Hermann 6aad465f08 Introduce a sane resource path to qt_add_qml_module
Since "/qt" is reserved, we can use "/qt/qml" as the default path for
user QML modules.

[ChangeLog][QtQml] The AUTO_RESOURCE_PREFIX option was added to
qt_add_qml_module(). It places your QML modules in the otherwise
reserved resource directory /qt/qml. This directory is also added to the
default QML import path. By using it you don't have to specify custom
import paths anymore. Specifying neither AUTO_RESOURCE_PREFIX nor an
explicit RESOURCE_PREFIX will generate a warning now because such QML
modules are likely invisible in the resource file system.

Fixes: QTBUG-95145
Fixes: QTBUG-103452
Change-Id: Ie27dec5cbf34ea06258d55c659d202cdd61e54b2
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-06-23 09:35:57 +02:00
Ulf Hermann 6a0ab2e8aa QmlCompiler: Fix miscompilation if arguments are overwritten
In that case we need to allocate extra registers. We already did so
before, but we wouldn't use the registers afterwards.

This works nicely in 6.4 because we have a separate type for each store
operation. Therefore, the original function argument (being of a
different "type") won't be found in the list of local registers. Access
to it falls back on the actual arguments array. Only once we've stored
something into the register that mirrors the argument we can retrieve
it.

Pick-to: 6.4
Fixes: QTBUG-104462
Change-Id: Ibb0315cd2f8a8e4106d39fff88a6097b1623eb48
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-23 09:35:57 +02:00
Ulf Hermann 87f9847144 QmlCompiler: Properly annotate ThrowException instruction
It doesn't write the accumulator, but it does read it. Generating code
for throwing exceptions reveals that we have to default-construct the
return type rather than converting from undefined/void when throwing an
exception.

Pick-to: 6.2 6.3 6.4
Fixes: QTBUG-104447
Change-Id: I0a725679d8ecb7e87bb20528033097bc0c3c7bb6
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-23 09:35:56 +02:00
Ulf Hermann e18919d3f2 QmlCompiler: Check builtin type aliases after list resolution
This way we can determine that QList<qreal> is the same as
QList<double>.

Pick-to: 6.4
Fixes: QTBUG-104129
Change-Id: I96df19da1a613558b950aa6cee46159024c19cc9
Reviewed-by: Evgeniy Dushistov <dushistov@mail.ru>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
2022-06-15 09:43:01 +02:00
Ulf Hermann fb3a81623a QmlCompiler: Reject conversions via QJSValue
Those are generally less efficient than what the interpreter would do,
they can have side effects, and they can throw exceptions. We don't want
to deal with any of that. Most of those implicit conversions have
explicit equivalents. For those that don't we can add them.

Pick-to: 6.2 6.4
Fixes: QTBUG-104010
Change-Id: I62898db92219386c94f2a6c9b56f6fb0b7578832
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-06-15 09:43:01 +02:00
Lucie Gérard 0dc4fd240a Use SPDX license identifiers
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>
2022-06-11 08:05:15 +02:00
Ulf Hermann 2a4ec96ae0 QmlCompiler: Don't retrieve metaobjects for value and sequence types
This is not valid QML, and the generated code crashes.

Pick-to: 6.2 6.4
Fixes: QTBUG-104092
Change-Id: If609acc2f2dc84a2e8f7c26d4d1b6c626f337cad
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-06-10 14:41:49 +02:00
Ulf Hermann 8e69558f2f qmltyperegistrar: Parse value type lists
We need to generate isList properties for those, so that qmlcachegen and
qmllint can handle them.

Pick-to: 6.4
Fixes: QTBUG-104129
Change-Id: I7e632279a605694c2fd5f583c8a6dcf9968eb634
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2022-06-10 14:41:32 +02:00
Ulf Hermann 8ea9646019 QmlCompiler: Don't crash when trying to resolve null list types
If the element type is unknown the list type is also unknown. This will
happen if we cannot resolve the type.

Fixes: QTBUG-103920
Change-Id: If1b05d99a1e64961981b5adb3974a51c11e776d2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-06-02 10:07:40 +02:00
Ulf Hermann 6ff6c088c2 QmlCompiler: Add support for LoadElement on strings
In JavaScript the [] operator on strings returns a string. QString's
operator[] returns a QChar, but we can easily create a string from that.

Fixes: QTBUG-103371
Change-Id: Id5c960f00ecc7a5dfe30ccbcaac3ffb2a30308b9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-24 15:44:16 +02:00
Ulf Hermann a75ddda71b QmlCompiler: Implement LoadElement for value type lists
Instead of the storedType hack in the type resolver, properly declare
the type LoadElement can return: A merge of undefined and the actual
type. This way we can choose the best concrete type to use for this
independently (and optimize it later).

Task-number: QTBUG-103529
Change-Id: I17b1f835f6a893ec843a90491e92f72ecb2e87fe
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-24 15:44:16 +02:00
Ulf Hermann 4d71091a19 qmlcompiler: Evaluate pragma ComponentBehavior
If components are bound we can assume the IDs of outer components are
reachable.

Fixes: QTBUG-102806
Fixes: QTBUG-101012
Change-Id: Ia26d3963d6c2fb9698debb12f9c655c5522f81ea
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-05-24 15:44:16 +02:00
Ulf Hermann 4a10e1d84a QmlCompiler: Detect non-integral values when accessing QQmlListProperty
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>
2022-05-19 22:30:23 +02:00
Ulf Hermann 70da741404 QmlCompiler: Do not coerce value type lists to QQmlListProperty
QQmlListProperty is only for object lists. Object lists are the only
thing we can use in LoadElement for now.

Fixes: QTBUG-103529
Change-Id: Ia120addcfc0afcbf1815d1bd9671f20df8334744
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2022-05-18 19:40:58 +02:00
Sona Kurazyan 2c9c1590e6 Replace uses of deprecated _qs with _s/QStringLiteral
Task-number: QTBUG-101408
Change-Id: Ic925751b73f52d8fa5add5cacc52d6dd6ea2dc27
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2022-04-29 09:47:43 +02:00
Ulf Hermann c751647430 QmlCompiler: Add test case for descriptive name of invalid type
Task-number: QTBUG-102147
Fixes: QTBUG-102968
Change-Id: Ifa6ab7490ed914f08da19b6928aeb1b105c448e5
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-28 22:50:25 +00:00
Ulf Hermann 871024cdce QmlCompiler: Fix licenses in test files
Those are not commercial-only anymore.

Change-Id: I4ebb6fa4b8295b9e5cbb901ab39e30df6e0c85ce
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-28 09:43:36 +02:00
Ulf Hermann 4ab857c37b QmlCompile: Double-check types before generating lookups
In case of incomplete type information, we can get QJSValue as output
type where we expect QObject*. We cannot generate any sensible code for
that.

Change-Id: If817de7dca3b5b0b58aff92dec2dd12a7c10d250
Pick-to: 6.2 6.3
Fixes: QTBUG-102554
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-25 08:44:43 +02:00
Ulf Hermann 5fdb88bcc1 QmlCompiler: Fix scopeObjectDestruction test case on android
Apparently we cannot close the dialog anymore once it has been opened.
Use a non-native dialog instead.

Pick-to: 6.2 6.3
Change-Id: Iced08fe83fcaa9890d002cf91f73987c1ee97a95
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-11 12:12:09 +00:00
Ulf Hermann 8a229c38fb QmlCompiler: Analyze type conversions before reads in basic blocks
The type conversions happen before the value is read. Therefore, we need
to record them in this order. Otherwise, we may lose a type conversion
if the instruction writes the same register as it reads.

Fixes: QTBUG-102281
Change-Id: Id63a69f86af90c8dc987c0301db3958322c006a1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-06 17:12:50 +02:00
Ulf Hermann a55299615f QmlCompiler: Fix string-to-bool conversion via QJSPrimitiveValue
We had a typo in there.

Pick-to: 6.2 6.3
Fixes: QTBUG-102309
Change-Id: I11eb9d35fde3b92d2e48e845740379e10c53774a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-06 17:12:41 +02:00
Ulf Hermann 0b63f3b66d QmlCompiler: Respect qualified property types
Factor out the name construction routine duplicated all over the place
and apply it to all places where it was missing.

Fixes: QTBUG-102147
Change-Id: I7c93b4878cedf3489b978591da8d8dfbb2b98c9b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-06 05:02:34 +02:00
Ulf Hermann d425712e93 QmlCompiler: Allow primitive conversion from any number to bool
Task-number: QTBUG-102281
Change-Id: I0dac4ce9c86c55e52283a6e05b0c3c0cc46551be
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-05 14:27:12 +02:00
Ulf Hermann c12f0f07f5 QmlCompiler: Improve ambiguous type detection
When detecting an ambiguous type, we need to invalidate the entry in the
list of types, rather than delete it. If we delete it and we get yet
another version of the type, we'll add that one just like it was not
ambiguous.

Furthermore, we cannot check the type name when looking for ambiguity.
The QML name can be bent and twisted in various ways, to import
ambiguous-looking types under different names, so that they are actually
not ambiguous.

Pick-to: 6.2 6.3
Fixes: QTBUG-102153
Change-Id: Iee7951229c5f68b168899e55164e8cf91587eec1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-04-01 20:58:49 +02:00
Ulf Hermann 5901fba811 QmlCompiler: Fix a number of warts regarding type lookup
There was a condition missing in qqml.cpp making most type lookups crash
right away. Furthermore, we need to generate code for type lookups we do
need. Finally, the shadow check should skip instructions we don't need
anymore. Shadowing in optimized-out code is not very interesting.

Pick-to: 6.2 6.3 6.3.0
Change-Id: I34e9de7686528b39a35e59c616e4e28b32a6e031
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-23 12:29:26 +01:00
Ulf Hermann 8a9607acfc QmlCompiler: Support type lookups in prefix-imported modules
We just have to return a plain metaType if it's neither an attached type
nor a singleton.

Pick-to: 6.3
Fixes: QTBUG-101811
Change-Id: I6a78ffe4504606d0cb34f1a6ca9d5511a3447d7f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-22 17:47:47 +01:00
Ulf Hermann 6eff3465b5 QmlCompiler: Implement generate_DefineArray
Using the type cloning and adaption mechanism we can now determine what
kind of list we have to create in order to avoid a later conversion. We
can even propagate the type adjustment into the element types we read.

Fixes: QTBUG-100157
Change-Id: Ia2f160ebae56f39ee5946f49d2f8c5b4986a6b77
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-14 20:53:52 +01:00
Ulf Hermann 1e722f5e8e QML: Handle dynamic meta objects in AOT lookups
If we are dealing with dynamic metaobjects, the QML engine may not
create property caches. We cannot see this at compile time. Therefore,
we need to establish a fallback infrastructure that does the same
operations on plain QMetaObject.

Pick-to: 6.2 6.3
Fixes: QTBUG-101349
Change-Id: I8c936fc077b0018df71196620b6987825253cb39
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-03 18:44:38 +01:00
Ulf Hermann 074b66e007 QmlCompiler: On MoveReg, check if we need to move at all
As we don't store void, null and empty lists, moving those is a noop.
Don't generate invalid code for that.

Pick-to: 6.2 6.3
Change-Id: Ica6714acd0ce8a5ddca44d9a397e776eb3df4247
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-03-01 08:51:52 +01:00
Ulf Hermann 23ab2e0f55 QmlCompiler: Correctly label arguments and return types of JS functions
Returning void from any JS function doesn't quite cut it.

Pick-to: 6.3
Fixes: QTBUG-101285
Change-Id: I199813627614061ec25139277e8ea23cb844aac5
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2022-02-25 14:08:22 +01:00
Ulf Hermann 78e3b774ad QmlCompiler: Don't assert for the "int" type if we don't need it
If there are no enums in a type, we don't need the int type to resolve
them. This is commonly the case for sequence types.

Change-Id: I18b2960ef845ef797b6ef6d755648e6add1854db
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-24 12:16:41 +01:00
Ulf Hermann c8e756e560 QML: Take care of QVariant when converting function arguments
We cannot convert to QVariant using QMetaType::convert(). But we can
just construct a QVariant with the desired type and data. This will
become an issue once we automatically convert argument types to match
the desired type inside the function.

As a side effect, also allow declaring "var" arguments to functions.

Change-Id: Idc14021d8d85d3d09ee7b7f286de91b56ea02bfd
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-23 12:09:42 +01:00
Ulf Hermann 88147eb3f6 QmlCompiler: Avoid infinite loop in dead store elimination
We have to mark the required variables also in block 0. And we shouldn't
generate empty blocks.

Pick-to: 6.3
Fixes: QTBUG-101011
Change-Id: I0dd19f69f45f507cb83e2ddfba3060de48a940b4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-18 16:48:50 +01:00
Ulf Hermann d0f4e0c037 QmlCompiler: Perform QVariant conversion in JavaScript semantics
In JavaScript we have a number of extra conversions not covered by
qvariant_cast. Therefore, add a method to perform a QVariant conversion
in JavaScript semantics to QJSEngine, and use that in the compiler.

Pick-to: 6.3
Fixes: QTBUG-100883
Change-Id: I8b0bfa0974bc6b339d2601fb373859bc710788c8
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>
2022-02-18 12:13:47 +01:00
Ulf Hermann 69fefd94e8 QmlCompiler: Do not crash on attempts to lookup a function in the scope
Rather, reject the code and let the engine handle it.

Pick-to: 6.2 6.3
Fixes: QTBUG-100980
Change-Id: Ibcd1249ba3550b40121622752b4ca22d1df3ed2a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Jarkko Koivikko <jarkko.koivikko@code-q.fi>
2022-02-18 12:13:47 +01:00
Ulf Hermann 795d7dafe5 QmlCompiler: Do not generate block comments into C++ code
The code we're commenting could again contain block comments. You cannot
nest them.

Pick-to: 6.2 6.3
Fixes: QTBUG-100978
Change-Id: I78685bf29dd30f05e5a3b17abc43ba0b4cb6849e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2022-02-18 12:13:47 +01:00
Ulf Hermann 4c716dd19c QmlCompiler: Correctly encode inf/nan/-0 into C++
Pick-to: 6.2 6.3
Fixes: QTBUG-100947
Change-Id: If0b05adac91f687daf697f3510e4cf48e7de4537
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-18 12:13:47 +01:00
Ulf Hermann 89b7e8def6 QmlCompiler: Allow assigning empty lists to list properties
Generate an empty list when creating a list with 0 elements.

Task-number: QTBUG-100157
Change-Id: I3b0fe0b737a8ec5257785ae32231f4b687d3b204
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-14 12:38:10 +01:00
Ulf Hermann f99b2cce65 QmlCompiler: Don't store void and nullptr
We know what those are. We don't need to put them into the generated
code. Do reserve variable names for those types, though. That makes
things easier.

Change-Id: I526eb862d1f5297bc3ddf91792eba87ef67fb9d2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-12 20:03:12 +01:00
Ulf Hermann db6459665c QmlCompiler: Place code for CmpNeInt in parentheses
Otherwise it will apply the '!' to the first argument.

Fixes: QTBUG-100480
Pick-to: 6.2 6.3
Change-Id: Iaefa25d062ad8bbd9d4278ffeaa52fc53ed417e2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-02-04 15:55:00 +01:00
Ulf Hermann 6728913542 Add missing dependencies to tst_qmlcppcodegen
Pick-to: 6.3
Change-Id: Ifb5af14faa8229d4f7025d275147044629f4f2cb
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2022-01-25 23:55:27 +01:00
Ulf Hermann 3747c02fe6 QmlCompiler: Handle ID lookups of incomplete types correctly
Incomplete types are generally stored in some wrapper type. We cannot
just assign to the accumulator. Also, we already know whether we have an
ID lookup there. No need to determine it again.

Pick-to: 6.2 6.3
Change-Id: I1f9fd9f147c44975df33fe862523987d8e711905
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-22 09:59:09 +01:00
Ulf Hermann e19d48d073 QmlCompiler: Respect revisions
The only place where revisions matter is at the boundary between
composite and non-composite types. The revision of the first composite
type inherited from determines which members of all composite ancestors
are available. Therefore, store the revision together with the base type
and pass it through the imports to have it available. Then use it to
check availability of methods and properties.

The test exposes two further problems, which are fixed, too:

1. If no method is found to call, we need to generate an error in the
   type propagator. We don't know what the call will result in, after
   all, and the code generator should reject it.
2. We need to check the right scopes for hasOwnMethod(). Otherwise we
   might not find methods that are available.

Pick-to: 6.2 6.3
Fixes: QTBUG-99128
Change-Id: I4c320b8dfb490b140d7b8c16e6b638b32f156faa
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2022-01-21 01:23:58 +01:00
Ulf Hermann 6a54c6013d QmlCompiler: Handle context push/pop in dead code
Otherwise we end up with unmatched curly braces in the generated code.

Pick-to: 6.2 6.3
Change-Id: I4c24d4062a8ed54cd6a9ecb43dfd2b5d0a26c9e1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
2022-01-18 12:51:38 +01:00
Ulf Hermann bd0f4459ce Re-allow retrieval of list properties in QQmlJSCodeGenerator
It's not particularly slow. It probably was when we were using
QQmlListReference or JavaScript arrays.

Pick-to: 6.3
Change-Id: I1a4575a5b84cdfb732a6c3615d00bbe2abaffc94
Reviewed-by: Fawzi Mohamed <fawzi.mohamed@qt.io>
2022-01-15 14:22:42 +01:00
Maximilian Goldstein fddd82345a qqmljstypepropagator: Add compiler error for unknown function calls
Previously we would not generate an error when an unknown function was
called.

Pick-to: 6.2 6.3
Change-Id: I31845a642afe0fd6038228c4aabf2ef5c6f1140e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2022-01-13 15:35:31 +01:00
Ulf Hermann 0ea14fa126 QmlCompiler: Don't try to get attached objects for non-QObject*
We might end up in this situation if we don't know enough about the
base of the attached lookup. This would generate invalid C++ code.

Pick-to: 6.2 6.3
Change-Id: I210077388d0d1d0d4e9454bd3ba3792af9b42049
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-17 12:43:14 +01:00
Ulf Hermann 22f4306283 QmlCompiler: Reject ambiguous and inaccessible types
If a type is not accessible in the imported version of a module, exclude
it. If we find multiple types for the same name and version, drop them
all and warn.

Pick-to: 6.2 6.3
Fixes: QTBUG-99113
Change-Id: I91d99d603ada6cf87f84afdbb01a543880d9aa76
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-13 11:51:06 +00:00
Ulf Hermann dd0b82abdc QQmlJSImportsVisitor: Break inheritance cycles
If we keep them around, later passes on the same data may run into
infinite loops. We cannot fully prevent any further processing of the
data because the import can happen from deep within a hierarchy of
components and modules.

Also, separate the deprecation check from the inheritance check.

Pick-to: 6.2
Change-Id: I62ce7cd15be83f60cd72b63ab858632fbc7dea66
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-12 12:05:28 +01:00
Ulf Hermann 2aa118c118 QQmlJSAotContext: flushPendingBinding() before capturing a property
This avoids duplicate evaluation and binding loops.

Pick-to: 6.2
Change-Id: I5eba42d9dca0782dd964bd64c088c2e158faa9b3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-10 10:06:28 +01:00
Ulf Hermann af356e3bc8 qmlcachegen: Don't generate bad code if we cannot resolve a return type
If we cannot resolve a return type, we need to refrain from calling the
method.

Pick-to: 6.2
Task-number: QTBUG-99042
Change-Id: Ie5ba0367c83c178f7e5c112072ca97d3c1c1fb1f
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-10 02:42:47 +01:00
Ulf Hermann 25333a6af2 QmlCompiler: Split type name by last "::" rather than first
The outer type name can include namespaces, the inner one cannot.

Task-number: QTBUG-99042
Change-Id: Idaa3abbfa7b4ff0c908edd7fdee5c4e2ba0337dc
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-10 02:42:47 +01:00
Andrei Golubev 9dc7c21321 Fix top-level build of qmlcppcodegen tests
The following is observed with a clean top-level build:
CMake Error: AUTOMOC for target codegen_test_moduleplugin: The "moc" executable "<path>/qt5/qtbase/libexec/moc" does not exist.
CMake Generate step failed.  Build files cannot be regenerated correctly.
CMake Error at /home/ag/work/qt5/qtbase/cmake/QtProcessConfigureArgs.cmake:928 (message):
  CMake exited with code 1.

Amends 58ff7aa4fe

Change-Id: I5b617de11520e13decb987bea377430b7a23fc75
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-06 22:43:08 +01:00
Ulf Hermann 1003626e6a QmlCompiler: Fix return type calculation
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>
2021-12-06 19:35:50 +01:00
Ulf Hermann b7b5127747 Test that we can retrieve attached types from "recursive" names
This is what the various SelectionRectangle.qml types in qqc2 do. Amends
commit e6c44662cdc8acfbdbf1c7ed071e1253ff0c1321.

Change-Id: Icb98f262d669ed165a3b3ab1be79b150b6cedc44
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-04 17:11:27 +01:00
Ulf Hermann 58ff7aa4fe Compile QML files ahead of time with qmlcachegen
qmlcachegen compiles bindings and functions to C++ as far as
QQmlJSAotCompiler can. It does respect "pragma Strict" and rejects the
file if it's violated. Furthermore, it sets up the logger to follow the
qt.qml.compiler.aot logging category. By default it's completely silent.

Compiling the examples with qmlcachegen exposes a bug in the type
resolver where it returns an invalid generic type. It should never do
that. Fix it by returning JSValue.

[ChangeLog][QtQml][Important Behavior Changes] QML bindings and
functions are now compiled to C++ by qmlcachegen, if possible. Use the
qt.qml.compiler.aot logging category to receive diagnostics about the
compilation.

Task-number: QTBUG-98305
Change-Id: I6953812c3fd20b68339617a5714fcbe16a384360
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-03 12:09:26 +01:00