diff options
| author | Ulf Hermann <ulf.hermann@qt.io> | 2026-09-30 14:25:27 +0200 |
|---|---|---|
| committer | Ulf Hermann <ulf.hermann@qt.io> | 2026-09-30 16:03:58 +0000 |
| commit | 5a2e8ea4a2edf4a781ed460c25647f7400a3c159 (patch) | |
| tree | 73a35b86bcee1eb438edc91d7f30f4b705fffdad | |
| parent | 9a0933e326bf51b0b4633f8e8f03c1ee95672460 (diff) | |
QmlCompiler: Restructure result handling
gcc 14 has a well-known bug that causes false positive warnings when
move-assigning std::variant and std::optional. Here, we don't actually
need to do that, though. Handling the result in a dedicated lambda is
nicer anyway.
Change-Id: I8fb41d870e5391c21ff99e92c8b85784965cfd78
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
| -rw-r--r-- | src/qmlcompiler/qqmljscompiler.cpp | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/src/qmlcompiler/qqmljscompiler.cpp b/src/qmlcompiler/qqmljscompiler.cpp index 1e70350cd8..4696f1a555 100644 --- a/src/qmlcompiler/qqmljscompiler.cpp +++ b/src/qmlcompiler/qqmljscompiler.cpp @@ -232,7 +232,25 @@ bool qCompileQmlFile(QmlIR::Document &irDocument, const QString &inputFileName, std::sort(bindingsAndFunctions.begin(), bindingsAndFunctions.end()); std::for_each(bindingsAndFunctions.begin(), bindingsAndFunctions.end(), [&](const BindingOrFunction &bindingOrFunction) { - std::variant<QQmlJSAotFunction, QList<QQmlJS::DiagnosticMessage>> result; + using Result = std::variant<QQmlJSAotFunction, QList<QQmlJS::DiagnosticMessage>>; + const auto processResult = [&](const Result &result) { + if (auto *errors = std::get_if<QList<QQmlJS::DiagnosticMessage>>(&result)) { + for (const auto &error : *errors) { + qCDebug(lcAotCompiler) << "Compilation failed:" + << diagnosticErrorMessage(inputFileName, error); + } + } else if (auto *func = std::get_if<QQmlJSAotFunction>(&result)) { + if (func->skipReason.has_value()) { + qCDebug(lcAotCompiler) << "Compilation skipped:" + << func->skipReason.value(); + } else { + qCDebug(lcAotCompiler) << "Generated code:" << func->code; + auto index = object->runtimeFunctionIndices[bindingOrFunction.index()]; + aotFunctionsByIndex[index] = *func; + } + } + }; + if (const auto *binding = bindingOrFunction.binding()) { switch (binding->type()) { case QmlIR::Binding::Type_AttachedProperty: @@ -288,7 +306,7 @@ bool qCompileQmlFile(QmlIR::Document &irDocument, const QString &inputFileName, qCDebug(lcAotCompiler) << "Compiling binding for property" << irDocument.stringAt(binding->propertyNameIndex); - result = aotCompiler->compileBinding(context, *binding, node); + processResult(aotCompiler->compileBinding(context, *binding, node)); } else if (const auto *function = bindingOrFunction.function()) { if (!aotCompiler->isLintCompiler() && !function->isQmlFunction) return; @@ -302,25 +320,10 @@ bool qCompileQmlFile(QmlIR::Document &irDocument, const QString &inputFileName, const QString functionName = irDocument.stringAt(function->nameIndex); qCDebug(lcAotCompiler) << "Compiling function" << functionName; - result = aotCompiler->compileFunction(context, functionName, node); + processResult(aotCompiler->compileFunction(context, functionName, node)); } else { Q_UNREACHABLE(); } - - if (auto *errors = std::get_if<QList<QQmlJS::DiagnosticMessage>>(&result)) { - for (const auto &error : std::as_const(*errors)) { - qCDebug(lcAotCompiler) << "Compilation failed:" - << diagnosticErrorMessage(inputFileName, error); - } - } else if (auto *func = std::get_if<QQmlJSAotFunction>(&result)) { - if (func->skipReason.has_value()) { - qCDebug(lcAotCompiler) << "Compilation skipped:" << func->skipReason.value(); - } else { - qCDebug(lcAotCompiler) << "Generated code:" << func->code; - auto index = object->runtimeFunctionIndices[bindingOrFunction.index()]; - aotFunctionsByIndex[index] = *func; - } - } }); } |
