aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljslintercodegen.cpp
Commit message (Collapse)AuthorAgeFilesLines
* qmllint: Introduce UserContextPropertiesSami Shalayel2025-07-311-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | Allow the user to specify context property names in .contextProperties.ini files so that they can disable all warnings or only the unqualified warning on their defined context properties by name. I remember some use cases where checking the .qmllint.ini into a users project repository is unwanted, so use a new setting file for the context properties that does not mess with global/system-wide .qmllint.ini files when checked into the repository. Create a new class called UserContextPropertiesSettings that is in charge of loading user context properties setting files, and use it inside of QQmlJSLinter. Introduce a ContextPropertyInfo class that contains both the heuristic information and the user-provided information. ContextPropertyInfo is used to pass the ContextProperty information down the type propagator. Also add some documentation for the new settings file. Task-number: QTBUG-138061 Task-number: QTBUG-128232 Change-Id: Icd700154dc89219f115fa3187c037d65451d0059 Reviewed-by: Fabian Kosmale <[email protected]>
* QQmlJSLinter: add crude context properties warningsSami Shalayel2025-05-221-6/+9
| | | | | | | | | | | | | | | | | | | | | | | Warn in QQmlJSTypePropagator::generate_LoadQmlContextPropertyLookup() about usages of context properties that were found. Also treat context properties as var. Add the (C++) location of the "setContextProperty()" call to the warning, and also hint that a property is assumed to be a context property when inside a top-level component (capital C Component, inline component or implicitly wrapped as component) because it is not declared as required property. Still print the accompanying unqualified warnings next to the new context property warning. Add a test. Later patches will add the support to qmlls and qmllint by passing the workspace folders to the new functionality. Task-number: QTBUG-128232 Change-Id: I26e39e0bce8c6e9f203962a091209c7acd15d445 Reviewed-by: Olivier De Cannière <[email protected]>
* Compiler: Add infrastructure to skip functionsOlivier De Cannière2025-04-171-0/+2
| | | | | | | | | | | | | | When trying to compile a function in the compiler, sometimes, the outcome is neither successful compilation nor an error. Introduce skiping functions for those cases. When a function is skipped its compilation has not failed. Skipping is therefore allowed in strict mode. Task-number: QTBUG-134790 Pick-to: 6.9 6.8 Change-Id: I0f1ca85404db8dd4c87cd5eb9b96c9dc8cc8d290 Reviewed-by: Sami Shalayel <[email protected]>
* qqmljslintercodegen: don't ignore the results from run()Sami Shalayel2025-04-111-12/+12
| | | | | | | | | The passes currently don't modify BasicBlocksAndAnnotations, but I think its nice to not ignore their return value, in case they start modifying annotations or basic blocks in the future. Change-Id: I4edcf6958a9a3cf65c91c5389fb42a1dd72d35db Reviewed-by: Olivier De Cannière <[email protected]>
* qqmljslintercodegen: prepare for QQmlJSBasicBlocksSami Shalayel2025-04-111-12/+23
| | | | | | | | | | | Modify QQmlJSLinterCodeGen to be able to run BasicBlock analysis. This is a preparation step to add the unreachable code analysis to QQmlJSLinterCodeGen. Task-number: QTBUG-129307 Change-Id: I94ae21759b6b863d9b9c2a632d9c3648ae3eb404 Reviewed-by: Ulf Hermann <[email protected]> Reviewed-by: Olivier De Cannière <[email protected]>
* QQmlJSLinterCodeGen: disable compiler checks when category is disabledSami Shalayel2025-02-181-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't run the compiler checks (QQmlJSStorageGeneralizer, QQmlJSStorageInitializer, QQmlJSShadowCheck) when the qmlCompiler category is disabled. They take quite some time and their result is ignored anyway if the qmlCompiler category is disabled. This allows to make the propertyStressTestInts benchmark faster, while the performance of the others stay the same. Times in milliseconds on my laptop, on a release build, before and after this patch: function,file,runtime_before -> runtime_after noPlugins,propertyStressTestInts.ui.qml,489 -> 323 noPlugins,propertyStressTestItems.ui.qml,612 -> 331 noPlugins,longQmlFile.ui.qml,175 -> 171 noPlugins,deeplyNested.ui.qml,197 -> 192 allPlugins,propertyStressTestInts.ui.qml, 493 -> 328 allPlugins,propertyStressTestItems.ui.qml, 630 -> 378 allPlugins,longQmlFile.ui.qml,192 -> 190 allPlugins,deeplyNested.ui.qml,215 -> 209 onlyQdsLintPlugin,propertyStressTestInts.ui.qml,535 -> 325 onlyQdsLintPlugin,propertyStressTestItems.ui.qml, 625 -> 336 onlyQdsLintPlugin,longQmlFile.ui.qml, 200 -> 180 onlyQdsLintPlugin,deeplyNested.ui.qml, 219 -> 206 Add another benchmark where compiler warnings are enabled in case we want to optimize the compiler's runtime in the future. Task-number: QTBUG-133349 Change-Id: Ia286d06c610b5134659f9c67ea18de3ca63955e9 Reviewed-by: Olivier De Cannière <[email protected]>
* QmlCompiler: Clean up error handlingUlf Hermann2025-02-021-36/+25
| | | | | | | | | | | | | | | | We should only have one way to handle diagnostic messages: The QQmlJSLogger. In addition each compile pass may result in an error that prevents the running of further passes. But that error should not rely on the selection of messages posted earlier. For this to work we need to introduce a further state transition into the logger. The logger now "archives" messages after compiling each function, so that only the current function's compile errors are taken into account as result of the current function's compilation. Task-number: QTBUG-124913 Change-Id: I4b6d9910b80527cefb1aba02598114d1fe5ba172 Reviewed-by: Olivier De Cannière <[email protected]>
* QmlCompiler: Do not post-process compile errorsUlf Hermann2025-01-241-37/+26
| | | | | | | | | | We can determine the correct QtMsgLevel and prefix early on and set that right away. Doing so will allow us to use the logger also for compiler errors and remove the extra list of messages in a second step. Task-number: QTBUG-124913 Change-Id: I145be21d0a210f07245aa19e3124634cdd4800b2 Reviewed-by: Fabian Kosmale <[email protected]>
* QmlCompiler: Reduce duplication of warnings about missing propertiesUlf Hermann2025-01-171-4/+8
| | | | | | | | | | | | If a property cannot be found, we don't need to check its type or even try to compile a binding for it. We also shouldn't claim a property doesn't exist if we cannot find it. We may have failed to resolve the type after all. Pick-to: 6.9 6.8 Task-number: QTBUG-124913 Change-Id: I93ef12e888762ae03f8fa6b1bef2e8d04ba3d4b2 Reviewed-by: Sami Shalayel <[email protected]>
* Compiler: Create infrastructure to support multiple warningsOlivier De Cannière2024-08-211-38/+46
| | | | | | | | | | | | | | | | | Currently only one DiagnosticMessage can be stored at a time when using the compiler. However, we want to be able to show more than one to the user. Therefore, use a list that gets passed inside the compiler instead of a pointer to the sole error. This also means that the error is valid by its very existence. There is no need to check validity explicitly anymore. Task-number: QTBUG-127624 Change-Id: I356db917b86703b508dc1ad52de7825d82eafd71 Reviewed-by: Ulf Hermann <[email protected]> Reviewed-by: Sami Shalayel <[email protected]>
* qmllint: avoid stale typeresolver pointerFabian Kosmale2024-07-021-0/+7
| | | | | | | | | | | | | It's not accessible via public API, but it risks wrecking havoc on internal plugins, and would also likely cause issues if we were to expose the global JS object to QQmlSA plugins. The current fix is rather a minimal workaround, we should revisit whether codegen should really take ownership of the typeResolver. Pick-to: 6.8 Change-Id: I6ca6e78527ce886155cfc0a21038348da2982c03 Reviewed-by: Ulf Hermann <[email protected]>
* QmlCompiler: Create QQmlJSRegisterContent unstoredUlf Hermann2024-06-161-0/+7
| | | | | | | | | | Add a separate pass to populate the stored types and only run that after we're done with all the type propagation and optimization. Task-number: QTBUG-124670 Change-Id: I740063908b22684f5d2c72d6261fad98850d8636 Reviewed-by: Olivier De Cannière <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
* Compiler: Extract Basic blocks generation into its own compiler passOlivier De Cannière2024-04-191-6/+8
| | | | | | | | | | | | | | | The old basic blocks pass was responsible for two things: the basic blocks generation and dead code analysis/type adjustments based on those blocks and the type propagation performed earlier. Now the basic blocks get generated first, even before the type propagation and the dead code analysis and type adjustments are now grouped in a pass called QQmlJSOptimizations. The rest of the passes remain unchanged. Change-Id: I7b4303eaf67c761a49b82ab194e5d035d24d2615 Reviewed-by: Fabian Kosmale <[email protected]> Reviewed-by: Ulf Hermann <[email protected]>
* QmlCompiler: Drop broken line comments in generated C++Ulf Hermann2023-02-231-1/+0
| | | | | | | | | | | | | | | | | | They didn't work because the ordering of instructions is not the same as the ordering of lines. They also weren't very helpful because a single line may result in multiple instructions and vice versa. On top of everything, they also introduced UB via the std::upper_bound call. Rather, just print the name of the function and the place in the file at the beginning of each C++ function. That is much more helpful since we can then just correlate it to the original QML code. For instruction-by-instruction mapping we have to consult the byte code trace anyway. Pick-to: 6.5 6.4 6.2 Fixes: QTBUG-111340 Change-Id: I599ce384cfaf88a7347583a55976a3b98080435d Reviewed-by: Fabian Kosmale <[email protected]>
* qmllint: Fix attached property re-use detectionUlf Hermann2023-02-141-4/+3
| | | | | | | | | | | | | | | | | | | | | Move the detection into the QtQuick lint plugin. It's mostly meant for QQC, so let's auto-enable it for attached types derived from QQuickAttachedPropertyPropagator. To this end, two new categories are introduced: The Quick lint plugin gets its own attached-property-reuse category which is synonymous to the default category of the same name. Furthermore, we add a controls-attached-property-reuse category for only checking controls. That one is implied by either of the others. Finally, fix the id vs. scope resolution to actually do something. This way we can give appropriate hints when the outer type has an ID already. Pick-to: 6.5 Fixes: QTBUG-110834 Change-Id: Ib71a9e3bbc10bac77f36db6cc441af88df20fd33 Reviewed-by: Fabian Kosmale <[email protected]>
* QmlCompiler: Handle trivial signal handler constructionsUlf Hermann2022-07-071-7/+8
| | | | | | | | | | | | | | 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 <[email protected]>
* Use SPDX license identifiersLucie Gérard2022-06-111-27/+2
| | | | | | | | | | | | 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 <[email protected]>
* Reimplement PropertyPass to evaluate bindingsMaximilian Goldstein2022-05-161-1/+2
| | | | | | | | | | | | | | | | | | | | | | This change reimplements the PropertyPass to be based on bindings rather than on just iterating over elements. This is a lot less cost intensive than iterating over all properties regardless of whether they are actually used. You may still achieve the same thing with the more flexible element pass, just with the benefit that you can choose what properties you want to iterate over instead of iterating over all of them. To demonstrate the passes usefulness the existing attached property warnings are ported to use the binding pass and can now also warn when an attached property is read or written in a context where it's not supposed to be used. Fixes: QTBUG-102860 Fixes: QTBUG-102418 Task-number: QTBUG-102859 Change-Id: Iea87a1b05b954429b8bf00fd27b60487940af679 Reviewed-by: Ulf Hermann <[email protected]> Reviewed-by: Qt CI Bot <[email protected]>
* Replace uses of deprecated _qs with _s/QStringLiteralSona Kurazyan2022-04-291-2/+4
| | | | | | Task-number: QTBUG-101408 Change-Id: Ic925751b73f52d8fa5add5cacc52d6dd6ea2dc27 Reviewed-by: Ulf Hermann <[email protected]>
* qmlcompiler: Remove qmllint libraryMaximilian Goldstein2022-02-031-0/+129
Since all of the superfluous components of qmllint have been removed now, we can just move what little custom linter logic remains to qmlcompiler. Change-Id: I91c752cb895e7d6c6f2dd4e2ccafb6cd05afa225 Reviewed-by: Andrei Golubev <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>