aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljslintercodegen.cpp
diff options
context:
space:
mode:
authorSami Shalayel <sami.shalayel@qt.io>2025-04-01 17:52:58 +0200
committerSami Shalayel <sami.shalayel@qt.io>2025-04-11 15:50:24 +0200
commit57a638d6640e5a8dbfbb0d2d488d4a32985e56ac (patch)
tree3ac600527b1029c29424164e37e99fe94d28b54d /src/qmlcompiler/qqmljslintercodegen.cpp
parentd9e8a229848f4d49d3911cace3e1d51870544305 (diff)
qqmljslintercodegen: prepare for QQmlJSBasicBlocks
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 <ulf.hermann@qt.io> Reviewed-by: Olivier De Cannière <olivier.decanniere@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljslintercodegen.cpp')
-rw-r--r--src/qmlcompiler/qqmljslintercodegen.cpp35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/qmlcompiler/qqmljslintercodegen.cpp b/src/qmlcompiler/qqmljslintercodegen.cpp
index 549387a6d3..8629281849 100644
--- a/src/qmlcompiler/qqmljslintercodegen.cpp
+++ b/src/qmlcompiler/qqmljslintercodegen.cpp
@@ -9,6 +9,7 @@
#include <QtQmlCompiler/private/qqmljsstorageinitializer_p.h>
#include <QtQmlCompiler/private/qqmljstypepropagator_p.h>
#include <QtQmlCompiler/private/qqmljsfunctioninitializer_p.h>
+#include <QtQmlCompiler/private/qqmljsbasicblocks_p.h>
#include <QFileInfo>
@@ -48,7 +49,7 @@ QQmlJSLinterCodegen::compileBinding(const QV4::Compiler::Context *context,
m_logger->setCompileErrorPrefix(u"Could not compile binding for %1: "_s.arg(name));
- analyzeFunction(&function);
+ analyzeFunction(context, &function);
if (const auto errors = finalizeBindingOrFunction())
return *errors;
@@ -70,7 +71,7 @@ QQmlJSLinterCodegen::compileFunction(const QV4::Compiler::Context *context,
});
m_logger->setCompileErrorPrefix(u"Could not compile function %1: "_s.arg(name));
- analyzeFunction(&function);
+ analyzeFunction(context, &function);
if (const auto errors = finalizeBindingOrFunction())
return *errors;
@@ -85,30 +86,40 @@ void QQmlJSLinterCodegen::setPassManager(QQmlSA::PassManager *passManager)
managerPriv->m_typeResolver = typeResolver();
}
-void QQmlJSLinterCodegen::analyzeFunction(QQmlJSCompilePass::Function *function)
+void QQmlJSLinterCodegen::analyzeFunction(const QV4::Compiler::Context *context,
+ QQmlJSCompilePass::Function *function)
{
- QQmlJSTypePropagator propagator(
- m_unitGenerator, &m_typeResolver, m_logger, {}, {}, m_passManager);
- auto [basicBlocks, annotations] = propagator.run(function);
+ bool dummy = false;
+ QQmlJSCompilePass::BlocksAndAnnotations blocksAndAnnotations =
+ QQmlJSBasicBlocks(context, m_unitGenerator, &m_typeResolver, m_logger)
+ .run(function, ValidateBasicBlocks, dummy);
+
+ blocksAndAnnotations = QQmlJSTypePropagator(m_unitGenerator, &m_typeResolver, m_logger,
+ blocksAndAnnotations.basicBlocks,
+ blocksAndAnnotations.annotations, m_passManager)
+ .run(function);
if (m_logger->isCategoryIgnored(qmlCompiler))
return;
if (!m_logger->currentFunctionHasCompileError()) {
- QQmlJSShadowCheck shadowCheck(
- m_unitGenerator, &m_typeResolver, m_logger, basicBlocks, annotations);
+ QQmlJSShadowCheck shadowCheck(m_unitGenerator, &m_typeResolver, m_logger,
+ blocksAndAnnotations.basicBlocks,
+ blocksAndAnnotations.annotations);
shadowCheck.run(function);
}
if (!m_logger->currentFunctionHasCompileError()) {
- QQmlJSStorageInitializer initializer(
- m_unitGenerator, &m_typeResolver, m_logger, basicBlocks, annotations);
+ QQmlJSStorageInitializer initializer(m_unitGenerator, &m_typeResolver, m_logger,
+ blocksAndAnnotations.basicBlocks,
+ blocksAndAnnotations.annotations);
initializer.run(function);
}
if (!m_logger->currentFunctionHasCompileError()) {
- QQmlJSStorageGeneralizer generalizer(
- m_unitGenerator, &m_typeResolver, m_logger, basicBlocks, annotations);
+ QQmlJSStorageGeneralizer generalizer(m_unitGenerator, &m_typeResolver, m_logger,
+ blocksAndAnnotations.basicBlocks,
+ blocksAndAnnotations.annotations);
generalizer.run(function);
}
}