aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
diff options
context:
space:
mode:
authorOlivier De Cannière <olivier.decanniere@qt.io>2025-11-20 11:32:18 +0100
committerUlf Hermann <ulf.hermann@qt.io>2025-11-27 11:58:31 +0100
commit8890b4a2d56ebdd51bf550d307f48d60ccf9a632 (patch)
tree43be5a38e62cb0692f26500dc175e35f509e1266 /tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
parentf07663052e265dee0ba16914bbcfbbf13ce295ea (diff)
Compiler: Stop std::move-ing the changed register in certain cases
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>
Diffstat (limited to 'tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp')
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 822747f9cc..c968196693 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -203,6 +203,7 @@ private slots:
void methodOnListLookup();
void methods();
void modulePrefix();
+ void moveAliasedRegister();
void multiAdjust();
void multiDirectory_data();
void multiDirectory();
@@ -4147,6 +4148,22 @@ void tst_QmlCppCodegen::modulePrefix()
QCOMPARE(rootObject->property("baz").toString(), QStringLiteral("ItIsTheSingleton"));
}
+void tst_QmlCppCodegen::moveAliasedRegister()
+{
+ QQmlEngine engine;
+ QQmlComponent component(&engine, QUrl(u"qrc:/qt/qml/TestTypes/moveAliasedRegister.qml"_s));
+
+ QVERIFY2(component.isReady(), qPrintable(component.errorString()));
+ QScopedPointer<QObject> rootObject(component.create());
+ QVERIFY(rootObject);
+
+ const auto &hash = rootObject->property("layout").toHash();
+ QCOMPARE(hash["a"_L1].typeName(), "bool");
+ QCOMPARE(hash["a"_L1].toBool(), false);
+ QCOMPARE(hash["b"_L1].typeName(), "bool");
+ QCOMPARE(hash["b"_L1].toBool(), false);
+}
+
void tst_QmlCppCodegen::multiAdjust()
{
QQmlEngine engine;