aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler
Commit message (Collapse)AuthorAgeFilesLines
* QmlCompiler: Don't read out of bounds when analyzing splice()Ulf Hermann31 hours1-2/+3
| | | | | | | | | | You can call splice with only one argument, after all. Pick-to: 6.10 6.8 6.5 Fixes: QTBUG-142253 Change-Id: I3dec244325fd4d57a045ec024968e26e4f6372db Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Compiler: Stop std::move-ing the changed register in certain casesOlivier De Cannière5 days1-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | This patch removes an optimization where we std::move the changed register into its target. A copy is performed instead. This resolves the more urgent issue of miscompilations. QTBUG-141920 has popped up and was either exposed or introduced by b303e0624d2ea2ab1c124961e7510a64d0ca1412. That change performs optimizations that avoid intermediary copies of values between registers. It was found that, in the process, the mapping from RegisterContent to variable name stored in m_resiterVariables was changed. One RegisterContent no longer uniquely maps to a variable name because of the direct moving of values to their destination. The registers alias the same value. This could cause issues and might need to be addressed. The original std::move was only added after 6.5 by 3193911b02424dd0365e03526a4c12ed7888b7ca. Cherry-pick to the later versions. Fixes: QTBUG-141920 Pick-to: 6.10 6.8 Change-Id: Ie6dad1a809ac5ee08de70971ec92d3c97fc50080 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qmllint: enhance duplicate property messageSami Shalayel5 days1-2/+11
| | | | | | | | | Add some information what the original attribute is (a signal, method or property). Task-number: QTBUG-141854 Change-Id: Ia4c6ea889b99658df2a6f5ee80e7b5628e398c8c Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qmllint: enhance getScopeName for shadow warningSami Shalayel5 days1-0/+3
| | | | | | | | | Print the qml name of root file name components instead of its base type when using getScopeName. Task-number: QTBUG-141854 Change-Id: I53f830a03edeaf0a23251583d4fa20da9ee8f5d0 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qmllint: warn on shadowed properties/signals/methodsSami Shalayel5 days3-14/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Warn when shadowing properties/signals/methods in qmllint. Move the already existing duplicate property check into its own static method warnForDuplicates, and extend it to check whether base types also have a property of the same name. Use it when analysing definitions of methods, signals and properties in qmljsimportvisitor to warn about shadowed properties. As a drive-by change, fix the sourcelocation of the duplicated property warning to point to the name of the property/signal/method instead of the "property" or "function" keyword. To avoid adding more testcases to the already big tst_qmllint::dirtyQmlSnippets_data(), create a new tst_qmllint::shadow_data() method for the shadow related tests, and make tst_qmllint::shadow() call dirtyQmlSnippet(). This allows to reuse the test code from dirtyQmlSnippet without making dirtyQmlSnippets_data grow even more. Adapt some existing test-cases by adding qmllint disable directives where shadowing was wanted, and disable the shadow category on tst_qqmljsscope (which does not make use of the qmllint code that reads qmllint disable directives), as it seems that tst_qqmljsscope tests that shadowing works as expected (shadowing is a feature, after all...). I guess this patch might need to be updated in the future once we have override and virtual properties in QML via QTBUG-98320. Make the qmlShadow warning non-critical for qmltc, as qmltc supports shadowing, to avoid breaking the qmltc tests. Task-number: QTBUG-141854 Change-Id: I74c1b413e2c19a0db34215b34a9b65d43fbef6ce Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qqmljsscope: add methodFromOwner methodSami Shalayel5 days2-3/+20
| | | | | | | | | | Add a method to grab the owner of a method of a qqmljsscope, in the same way as ownerOfProperty() does. A later patch will use it to warn about shadowed methods. Task-number: QTBUG-141854 Change-Id: I21247151ee3d7d298329d0bdfb2f5e0e1dd51b33 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* Remove redundant Q_FLAGS from classes that don't inherit from QObjectAhmad Samir5 days1-1/+0
| | | | | | Pick-to: 6.10 6.8 6.5 Change-Id: I810a7137470e0ee96c76819766ede2e9bc643d73 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: don't mixup 'import' and 'import-file-selector' categoriesSami Shalayel6 days3-13/+14
| | | | | | | | | | | | | | | | | | Don't log warnings of the import-file-selector category using the import category, and only use the import-file-selector category for that. It seems the mixup happened when multiple import and import-file-selector warnings were emitted for the same file, so extend the current test by introducing another qmllint warning with Broken.qml, and make sure the import-file-selector warning is emitted via the correct category-warning-level. The import category has warning level 'warning' while import-file-selector has 'info'. Amends 3ab60f40d5e0b612c6a1eedba656f4f26d66c927. Pick-to: 6.10 Change-Id: I35acdef46284067a9f23288128108569faa9d90b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: fix typo in warningSami Shalayel11 days1-1/+1
| | | | | | | | Add a missing i in "initalizer". Pick-to: 6.10 Change-Id: I3904fa88fcc499a0f7b2b8eb8884adecee10757b Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qmllint: fix required property detection on shadowed propertiesSami Shalayel11 days1-1/+12
| | | | | | | | | | | | | | | When a derived type shadows a property from its base type, qmllint used to confuse the base property's `required` status with the derived property's `required` status. This used to lead to bogus warnings even when the shadowing property was correctly bound. The check now ensures that the property owner matches before treating a property as required, fixing false positives in such cases. Pick-to: 6.10 Fixes: QTBUG-141086 Change-Id: Ic2cf6558a1ebf78af1022911827c398164de5e31 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QQmlJSAnnotation: mark relational operators noexceptMarc Mutz11 days1-3/+5
| | | | | | | | | | | | | | | | | (incl. qHash()) Because they are. Amends d226e24a5d4288a3e7f263c526cb6cbf72255388. Even though this breaks forward BC, we can pick this back since it's private API. Coverity-Id: 895832 Pick-to: 6.10 6.8 6.5 Change-Id: Ic9989afce02eb66dc0caf545ccfe7e54ccf99261 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QQmlJSAnnotation: say what you do (check valueless_by_exception())Marc Mutz11 days1-1/+1
| | | | | | | | | | | | | Yes, v.index() == std::variant_npos when v.valueless_by_exception(), but don't require readers to know that. Say what you're checking for, call valueless_by_exception(). Amends d226e24a5d4288a3e7f263c526cb6cbf72255388. Pick-to: 6.10 6.8 6.5 Change-Id: I6794adc320d5c4d0c188a9dbd1a8acb953bacfd4 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QQmlJSAnnotation: use non-throwing std::variant inspectionMarc Mutz12 days1-4/+6
| | | | | | | | | | | | | | | | | | | | | | | Coverity complained that the get<>() calls can throw an exception that percolates all the way to main(). There are several errors that combine to generate this warning, not all of them in our code. E.g., Coverity should really not have a problem understanding that get<> won't throw if we checked for holds_alternative before. The qHash() function ought to have been marked as noexcept (qHash() mustn't throw; QHash isn't really prepared for that), std::visit() ought to have been used, though I appreciate the verbosity that would generate. So first try whether using get_if() shuts Coverity up. Incidentally, this makes the code DRY, improving readability. Amends d226e24a5d4288a3e7f263c526cb6cbf72255388. Pick-to: 6.10 6.8 6.5 Coverity-Id: 895832 Change-Id: I0ed444cf96d3bfd3792351b66901af58d8180a76 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: fix required property detection with aliasSami Shalayel2025-11-171-17/+14
| | | | | | | | | | | | | | | Iterate over all aliases that directly or indirectly points to the required property, and check whether it is in the root file scope. If it is in the root scope, than the required property can be satisfied by setting the alias, and we shouldn't warn about unsatisfied required properties int the QML component itself. Instead, we warn at the place where the QML component is instantiated if the alias is not set. Pick-to: 6.10 Task-number: QTBUG-141086 Change-Id: I9237d0afd2e427558ebc2b5cbc97beb5248ec6a3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QmlCompiler: Fix rejection of dynamic properties in object literalsUlf Hermann2025-11-111-25/+10
| | | | | | | | | | | | | | | | Since we early-return in a number of places, the condition needs to be checked first. Also, remove the dead code that tries to implement dynamic properties in object literals. Amends commits f839171eefbba670536262fa3b847d24bfdc627b and f47df45b4981d2d3eedfdbcf7574a7d2e2625627 which were mistaken in trying to support this case. Pick-to: 6.10 6.8 Fixes: QTBUG-141849 Change-Id: I34a6c47375b9e8fa1320259e3f335d304ce8e589 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* Doc: Fix QDoc warnings for internal classes and functionsJerome Pasion2025-11-072-1/+2
| | | | | | | | | | -Mark internal functions with \internal -Sometimes the solution is to have a \class command and marked internal -Fixed whitespace issues when the new marking introduced them Task-number: QTBUG-141665 Change-Id: I4f744aa94ca679da74b6c5e846e49a73346e2625 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Compiler: Rename QMLLINT_DEFAULT_CATEGORIES to BUILTIN in stead DEFAULTOlivier De Cannière2025-11-052-10/+10
| | | | | | | This helps avoid confusion with the default field for categories. Change-Id: Iceb9a2adeb928a0f801fab9c718a8ecc3ac8cd07 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmllint: Remove the unused m_isBuilin flag from qmllint PluginsOlivier De Cannière2025-11-052-3/+0
| | | | | Change-Id: If477518595f6c625101209b12e908e7e18a3b5c4 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmllint: Also lint inner functionsOlivier De Cannière2025-11-056-3/+114
| | | | | | | | | | | | | | | | | | | We were only collecting the 'QML' functions that would be passed to the AOT compiler. Other function types were ignored. Also collect those and pass them to the compiler but only use them when linting. Defer invistigating whether it is a good idea to try to compile JS functions as well to a later point. Logic in a few places was adapted with this changing assumption. [ChangeLog][QML][qmllint] qmllint will now lint inner functions, defined in javascript, in addition to top-level functions and bindings. Fixes: QTBUG-138845 Pick-to: 6.10 6.8 6.5 Change-Id: If6f62aeace8739442b6a1f355fad95ce19c0643c Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Fix side effect detection for callsUlf Hermann2025-10-311-12/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We cannot pass registers that are potentially affected by side effect as arguments to calls. For this to work, we need to sharpen the side effect detection some more. 1. A conversion is always "var" which can be affected by side effects. However, the actual question is whether one of the conversion origins can be affected by side effects. A conversion of "int" and "undefined", for example, can certainly not be affected. 2. When determining side effects we need to look at the original types, not the adjusted ones. Adjusted types are often "var" because we need to pass a value as "var" to some function. That doesn't mean the value can be affected by side effects, though. 3. When generating the write-back, we should first check if it's necessary at all before looking for side effects. Furthermore, we need to slightly adjust the deltablue benchmark since two values were potentially affected by side effects. The walkStrength may be shadowed by a type with internal structure. Only at the call site of the weaker() and stronger() functions it would then be collapsed into int. However, those function calls might change the original walkStrength, thereby producing a side effect for further calls. We can exclude this effect by collapsing to Number right away using the '+' operator. Finally, we need to make the initialization of the Categorizer benchmark non-Strict. The loop that writes into an array of type unknown until the return statement while calling a function on every iteration is obviously affected by side effects. However, the meat of the benchmark is actually not the initialization. So that should be fine. Pick-to: 6.10 6.8 Fixes: QTBUG-141420 Change-Id: Iad47eddcf0afaa4e502f1d151cf383a6fd23f5ba Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Doc: Qml Compiler: Fix internal documentation issuesTopi Reinio2025-10-314-10/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | Mark QQmlSA::PropertyPrivate \internal to fix QDoc warning: src/qmlcompiler/qqmlsa.cpp:727: (qdoc) warning: No output generated for function 'QQmlSA::PropertyPrivate::isReadonly()' because 'PropertyPrivate' is undocumented Move the \class topic for QQmlJSMetaPropertyBinding from a header to the .cpp file. Fixes: src/qmlcompiler/qqmljsmetatypes.cpp:53: (qdoc) warning: No output generated for function 'QQmlJSMetaPropertyBinding::translationDataValue()' because 'QQmlJSMetaPropertyBinding' is undocumented Mark QQmlJSImporter \internal, fixes src/qmlcompiler/qqmljsimporter.cpp:719: (qdoc) warning: No output generated for function 'QQmlJSImporter::importQmldirs()' because 'QQmlJSImporter' is undocumented. Pick-to: 6.10 Change-Id: I18f66b096b6f30941f55f5cfdae4800cafc0a51a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Paul Wicking <paul.wicking@qt.io>
* Remove qml-i18n example in qtdeclarative repoAlexandru Croitor2025-10-311-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | The qml-i18n example and the qtdeclarative repo itself depend on the LinguistTools CMake package, which is not available while building qtdeclarative. This results in: - missing build coverage for the example - a cyclic dependency, because qtdeclarative depends on qttools (because of LinguistTools), and qttools depends on qtdeclarative (because of qdoc needs) - we try to find a module that will never be available, unless qtdeclarative is built together with qttools in a top-level build - in certain cases, if the top-level build fails early enough, the cyclic dependency causes reconfigurations to fail Remove the example, the lookup of LinguistTools, and the linguist doc references to avoid all these issues. Replace the qt_add_translations reference in the docs of the QQmlApplicationEngine class with a snippet copy. Pick-to: 6.8 6.10 Task-number: QTBUG-141465 Change-Id: Id88603a3753f53dfac9f350e981073effda15eb1 Reviewed-by: Masoud Jami <masoud.jami@qt.io>
* UserCtxProperties: Avoid unnecesary copy of settingsOlivier De Cannière2025-10-281-1/+1
| | | | | Change-Id: I255e7dd673be773778b99aa634278dd1995c2305 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* Compiler: Avoid generating duplicate settings namesOlivier De Cannière2025-10-221-2/+4
| | | | | | | | | | | | The two computations may result in the same string. Insert the second one only if it is differnt. Amends c4455f1771483c8ed63d27454242f19b28b524b0 Pick-to: 6.10 Change-Id: I0c4df0cf6bb5bba2c1cf6c50b8a7f105718b85ee Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Compiler: Clean up LoggerCategoryPrivateOlivier De Cannière2025-10-222-32/+33
| | | | | | | | | Unfriend LoggerCategory and actually implement accessor functions. Amends cdd7fe05f676ed1664a156beaf63093237a3beac Change-Id: Iee580f98d84ec554467cb8ab779a4178c7f745fc Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmllint: Fix typo in assignmentInCondition warningOlivier De Cannière2025-10-211-1/+1
| | | | | | | | Amends ce69cc78c0aaa0afea5cd74d15ea37685948e6d0 Pick-to: 6.10 Change-Id: I43b514bc390f84151814eb74b3062c80162218c3 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: prefer enums over chained attached typeSami Shalayel2025-10-211-10/+9
| | | | | | | | | | | | | | | It seems that FlexboxLayout.Row is actually ambiguous: it could refer to the "Row" enum value, and to the attached type of "Row" which is attached on the attached type of "FlexboxLayout". Fix qmllint to follow the qml engine's interpretation of the thing, and resolve it as an enum instead of a chained attached type in QQmlJSTypeResolver. Pick-to: 6.10 6.8 Fixes: QTBUG-141194 Change-Id: I24e23f5fc92b0d007ff1d628b6286f85a60f10d8 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* Compiler: Actually read the value of a key passed to qmltypesOlivier De Cannière2025-10-201-1/+1
| | | | | | | | | | | | | We always set isJavaScriptBuiltin to true if the key was present instead of actually reading the value. This seems to have worked because the key was only added when it was true and the default value is false. Amends 578946437fb31edd6aa78612e9db8fed9a3eb210 Pick-to: 6.10 6.8 Change-Id: I91f533129d233b251e221bf05abdc919eb8957c6 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Augment the import warning for unspecialized list propertiesOlivier De Cannière2025-10-201-2/+4
| | | | | | Pick-to: 6.10 6.8 Change-Id: Ifd33df7fc2cfeb86c5af9a9dc752518c52d5b91b Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* qmlls: print import path information on hoverSami Shalayel2025-10-131-0/+5
| | | | | | | | | | This copies the effect that Qt Creator does when hovering on an import, and avoids invalid QtC codemodel information leaking through when hovering on the import path. Fixes: QTBUG-140915 Change-Id: I5e08973fb2d227c735a40d01f6404f4424897272 Reviewed-by: Semih Yavuz <semih.yavuz@qt.io>
* QmlCompiler: Expect singleton members to be shadowableUlf Hermann2025-10-081-3/+17
| | | | | | | | | | | | | | | | | | | | | | You can return an instance of a derived class from a singleton's create() method and that derived class can shadow members of the singleton. We have no choice but to run many singleton accesses through the shadow check. There are some exceptions: 1. Extended singletons can't be shadowed since their concrete type can't be known in advance and the respective QQmlType can't stitch the metaobjects together to make that happen. 2. Composite singletons can't have factory functions. They also cannot be shadowed. 3. If the whole class is final. We can't detect that, yet, though. Pick-to: 6.10 Fixes: QTBUG-140738 Change-Id: Ia6c235636aec723e834db0089a9471f3b0a1e2fa Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QmlCompiler: Fix write access to QVariantMapUlf Hermann2025-10-072-9/+48
| | | | | | | | | | | | Without this, it tries to resolve the metaObject of QVariantMap, which crashes. Amends commit cca07aa78841f2d743f0b4d933abb0dd66f0b948. Fixes: QTBUG-139626 Pick-to: 6.10 6.8 Change-Id: Id747429ed0d558932b9a6cb8f59e3740982efb56 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QQmlJSUtils::resourceFilesFromBuildFolders: port to QDirListingSami Shalayel2025-09-301-4/+5
| | | | | | | | | | | Use QDirListing instead QDirIterator in resourceFilesFromBuildFolders. QDirIterator is deprecated and shows up a bit in the profiler when investigating why tst_qmlls_modules::qmldirImports timeouts some time on a debug asan build. Pick-to: 6.10 Change-Id: Icc80c39f48ac381828829dc0d4c5eb51ed42abbf Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: Consider "on-bindings" for required propertiesFabian Kosmale2025-09-241-1/+5
| | | | | | | | | | | | | | The runtime doesn't complain if a required property is satisfied via a ValueSource or an Interceptor, so qmllint shouldn't complain either. Whether this really should apply to interceptors is debatable, but for now let's aim for consistency. And that a ValueSource can satifsy the requirement is arguably to be expected. Pick-to: 6.10 6.8 Fixes: QTBUG-139632 Change-Id: I355b8a48e6b9bc2749839267c3b799e8eba5d72f Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QmlCompiler: Don't adjust the same conversion multiple timesUlf Hermann2025-09-231-1/+1
| | | | | | | | | | | | The same conversion can re-surface in multiple places in the byte code by virtue of being stored and loaded unchanged. If we've already adjusted it, we don't need to do it again. Pick-to: 6.10 Fixes: QTBUG-140415 Change-Id: Ic1e7e90af49f0ee9440a9c37abd4ab8ee0fdbe3e Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QmlCompiler: Properly handle uncertain component statusUlf Hermann2025-09-188-73/+274
| | | | | | | | | | | | | | | | | | | | | | | | | | | In order to determine whether an ID is visible from a referrer we need not only determine the component boundaries of the referrer, but also those of the candidate elements with the respective ID. Rewrite the logic to have QQmlJSScopesById handle this. It has to iterate the respective elements anyway and can therefore easily check if one of them is assigned to an unknown property. It now provides low-level methods that output all possible candidates for an ID, while also stating the confidence associated with them. The plain id() and scope() methods only return results we are actually certain about. In places where we generate warnings or can allow for some fuzzy results, we use the low-level methods, since those generally produce more informative results. The QML DOM was passing the JavaScript global object as referrer to the scope() method before. This happened to work but was, of course, wrong. Make sure that ID elements in the DOM receive a proper QML scope to avoid that. Pick-to: 6.10 6.9 6.8 Task-number: QTBUG-140041 Change-Id: I41cf8603ae6a5d5461d3c12d74521e68b5e28ea4 Reviewed-by: Sami Shalayel <sami.shalayel@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* Tests: Clean up includesUlf Hermann2025-09-171-1/+2
| | | | | | | | | | | | | We shouldn't include qtqml-config_p.h manually since it's not header-guarded. And especially we shouldn't include it twice. Also, sort and split the includes. In order to resolve QT_CONFIG, we include qtqmlglobal_p.h or qtqmlglobal.h. Change-Id: I933d8eff8581e91859a8a178bf92caeec2959215 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* Add security header for src/qmlcompilerOlivier De Cannière2025-09-1780-0/+81
| | | | | | | | | | | | | | | | | | We assume that QML or JS code comes from a trusted source. Therefore, most files are deemed to be significant even if they parse data. This includes the source code itself but also the associated metadata or cache files. However, the QML compiler also generates C++ code. Extra care needs to be taken with the generator as a vulnerability there could propagate and have a disproportionate effect on the program's security. It is marked as critical. QUIP: 23 Fixes: QTBUG-136195 Pick-to: 6.10 6.9 6.8 Change-Id: I70630361ec8e9cb3969f78a3fdf36a41334a33b3 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qml compiler: avoid `interface` as var/parameter nameTim Blechmann2025-09-092-32/+33
| | | | | | | | | | | The win32 system headers define `interface` to `struct`. When using unity builds, this define can leak between source files and cause compile errors. This patch fixes unity builds. Pick-to: 6.10 Change-Id: I72192f406ace2bdb26e18d61fd80add26345d34a Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* QmlCompiler: Ensure QObjects returned to AOT-compiled code are wrappedUlf Hermann2025-09-023-10/+23
| | | | | | | | | | | | If a QObject is returned from a method call, the QML engine takes ownership of it and it needs to be deleted by the garbage collector. Our generated C++ code so far did not actually take ownership of the object and thereby caused it to leak. Pick-to: 6.10 6.9 6.8 Fixes: QTBUG-138919 Change-Id: I7bd57b3612bf4b98937756e8a7a7c03aff1c9b32 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QtQml: Mark values on the AOT-compiled stack during gcUlf Hermann2025-09-021-8/+45
| | | | | | | | | | Keep them in a special generated struct with virtual method that gets called from the GC for each frame. Pick-to: 6.10 6.9 6.8 Fixes: QTBUG-139059 Change-Id: I81bcbeab6531e174a5207d03f57d241461ae9ba3 Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* QmlCompiler: Fix access to optional QVariantMapUlf Hermann2025-09-012-5/+21
| | | | | | | | | | Without this, it tries to resolve the metaObject of QVariantMap, which crashes. Fixes: QTBUG-139626 Pick-to: 6.10 6.9 6.8 Change-Id: I9248f57c428810024f9983df959f475e6557576c Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
* QmlCompiler: Rename sequences' "valueType" to "elementType"Ulf Hermann2025-08-318-57/+59
| | | | | | | | | "valueType" is ambiguous. The prevailing meaning is a type that's passed by value in QML. We mean the type of the list contents (or elements) here. Change-Id: Iaf4c0efe272dc6ec7511d2361e7e5ce475936fba Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
* qmllint: Do not warn about QQmlPropertyMap accessFabian Kosmale2025-08-252-1/+6
| | | | | | | | | | A QQmlPropertyMap can store anything, and we can't know what is available. Treat it like QVariantMap as far as qmllint is concerned. Task-number: QTBUG-139240 Pick-to: 6.10 Change-Id: I9ebc0a963159cfc930ff14300df50b6fab5b7035 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: disable unqualified warning on user context property callSami Shalayel2025-08-222-27/+18
| | | | | | | | | | | | Amends 6575b0e835357dbf4f2a04c6df50abee4bda08ba that forgot to disable unqualified warnings on context property calls `myContext()`. Rename warnAboutContextPropertyUsage() into handleUnqualifiedAccessAndContextProperties() and make it handle unqualified access warnings when needed. Fixes: QTBUG-138061 Change-Id: I2fe3ab2a9c2ed1329589ce67a03c1f905542793e Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* qmllint: load .contextPropertyDump.ini from build folderSami Shalayel2025-08-213-7/+46
| | | | | | | | | | | | | | Make QQmlJSLinter read heuristic context properties (.contextPropertyDump.ini) files from the build directory, by searching them with QQmlToolingSettings::Searcher. Add a test that writes a .qrc file such that qmllint can find the "build" folder that contains the .contextPropertyDump.ini, and make sure that QQmlJSLinter warns about at least one context property. Task-number: QTBUG-128232 Change-Id: I52569acc38d2fcda5015fe38ef84967353dbc21d Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* HeuristicContextProperties: don't grep on empty argumentSami Shalayel2025-08-211-0/+3
| | | | | | | | | In HeuristicContextProperties::collectFromDirs, early return when an empty list is given, instead of running grep without directories (which defaults to the working directory). Change-Id: I96647112eab74e9d68c96aaf14511f06774009d4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmlcontextpropertydump: add extra feature flag to disable/enableSami Shalayel2025-08-211-5/+6
| | | | | | | | | Introduce a new feature flag to disable the qmlcontextpropertydump tool (that will be introduced in a later commit). Task-number: QTBUG-128232 Change-Id: I68436f1007ec40c6b3c8e1059319156251ecdef4 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* heuristic context properties: write and load to/from diskSami Shalayel2025-08-212-1/+130
| | | | | | | | | | | | | | | | | Add methods to write and load context properties on disk. Use the .ini format to provide human readable files and to be able to reuse QQmlToolingSettings for finding the setting file. Implement a simple (de)serialization of SourceLocations for the .ini files, and use QSetting to dump/read the lists of properties. Add a test to see if the (de)serialization works. Add equality operators where required for the test's Q_COMPARE(). Task-number: QTBUG-138061 Task-number: QTBUG-128232 Change-Id: I23bd2db0aacad3d395c2909efb209277f7f1d4bd Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
* qmllint: Update JSON format to include hints into fix suggestionsOlivier De Cannière2025-08-201-15/+2
| | | | | | | | | | | | | Hints are no longer their own fix suggestion but instead are part of an existing one. This breaks compatibility with the existing format but as the output is not documented and is versioned this should be ok. This change will enable having multiple fix suggestions per warning in a future change. Pick-to: 6.10 Change-Id: Iedf275507554a2d70399757396e278999874cd53 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>