From 5a2e8ea4a2edf4a781ed460c25647f7400a3c159 Mon Sep 17 00:00:00 2001 From: Ulf Hermann Date: Wed, 30 Sep 2026 14:25:27 +0200 Subject: 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 --- src/qmlcompiler/qqmljscompiler.cpp | 39 ++++++++++++++++++++------------------ 1 file 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> result; + using Result = std::variant>; + const auto processResult = [&](const Result &result) { + if (auto *errors = std::get_if>(&result)) { + for (const auto &error : *errors) { + qCDebug(lcAotCompiler) << "Compilation failed:" + << diagnosticErrorMessage(inputFileName, error); + } + } else if (auto *func = std::get_if(&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>(&result)) { - for (const auto &error : std::as_const(*errors)) { - qCDebug(lcAotCompiler) << "Compilation failed:" - << diagnosticErrorMessage(inputFileName, error); - } - } else if (auto *func = std::get_if(&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; - } - } }); } -- cgit v1.2.3