diff options
| author | Olivier De Cannière <olivier.decanniere@qt.io> | 2025-09-18 15:12:24 +0200 |
|---|---|---|
| committer | Olivier De Cannière <olivier.decanniere@qt.io> | 2025-11-05 13:43:51 +0100 |
| commit | a0a2a239dc8e1a486ae8bdf14ec7fd5db27311e1 (patch) | |
| tree | 7eab5e7b2f4078a91bc09b99f8b3bbacad749755 /src/qmlcompiler/qqmljscompiler.cpp | |
| parent | 7a94d502a8ded563e4f228b4cf00e879ce9a72fe (diff) | |
qmllint: Also lint inner functions
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>
Diffstat (limited to 'src/qmlcompiler/qqmljscompiler.cpp')
| -rw-r--r-- | src/qmlcompiler/qqmljscompiler.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/qmlcompiler/qqmljscompiler.cpp b/src/qmlcompiler/qqmljscompiler.cpp index 6a518b0acf..14ecd52610 100644 --- a/src/qmlcompiler/qqmljscompiler.cpp +++ b/src/qmlcompiler/qqmljscompiler.cpp @@ -5,6 +5,7 @@ #include "qqmljscompiler_p.h" #include <private/qqmlirbuilder_p.h> +#include <private/qqmljsaotirbuilder_p.h> #include <private/qqmljsbasicblocks_p.h> #include <private/qqmljscodegenerator_p.h> #include <private/qqmljscompilerstats_p.h> @@ -203,9 +204,11 @@ bool qCompileQmlFile(QmlIR::Document &irDocument, const QString &inputFileName, } { - QmlIR::IRBuilder irBuilder; - if (!irBuilder.generateFromQml(sourceCode, inputFileName, &irDocument)) { - error->appendDiagnostics(inputFileName, irBuilder.errors); + // For now, only use the AOT IRBuilder when linting + std::unique_ptr<QmlIR::IRBuilder> irBuilder = aotCompiler && aotCompiler->isLintCompiler() + ? std::make_unique<QQmlJSAOTIRBuilder>() : std::make_unique<QmlIR::IRBuilder>(); + if (!irBuilder->generateFromQml(sourceCode, inputFileName, &irDocument)) { + error->appendDiagnostics(inputFileName, irBuilder->errors); return false; } } @@ -320,6 +323,9 @@ bool qCompileQmlFile(QmlIR::Document &irDocument, const QString &inputFileName, << irDocument.stringAt(binding->propertyNameIndex); result = aotCompiler->compileBinding(context, *binding, node); } else if (const auto *function = bindingOrFunction.function()) { + if (!aotCompiler->isLintCompiler() && !function->isQmlFunction) + return; + Q_ASSERT(quint32(functionsToCompile.size()) > function->index); auto *node = functionsToCompile[function->index].node; Q_ASSERT(node); |
