aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmlcompiler/qqmljsoptimizations.cpp
diff options
context:
space:
mode:
authorOlivier De Cannière <olivier.decanniere@qt.io>2024-08-02 10:13:44 +0200
committerOlivier De Cannière <olivier.decanniere@qt.io>2024-08-21 19:57:58 +0200
commitd70abd83dc94d722cde6d4b19b9d35c5f4f19946 (patch)
tree1119f20b6f64d71b4602e7d4e39f7dc0c2caeec4 /src/qmlcompiler/qqmljsoptimizations.cpp
parent06577c9e80eb150b6b9e76e7805bfed1abbae82d (diff)
Compiler: Create infrastructure to support multiple warnings
Currently only one DiagnosticMessage can be stored at a time when using the compiler. However, we want to be able to show more than one to the user. Therefore, use a list that gets passed inside the compiler instead of a pointer to the sole error. This also means that the error is valid by its very existence. There is no need to check validity explicitly anymore. Task-number: QTBUG-127624 Change-Id: I356db917b86703b508dc1ad52de7825d82eafd71 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io> Reviewed-by: Sami Shalayel <sami.shalayel@qt.io>
Diffstat (limited to 'src/qmlcompiler/qqmljsoptimizations.cpp')
-rw-r--r--src/qmlcompiler/qqmljsoptimizations.cpp20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/qmlcompiler/qqmljsoptimizations.cpp b/src/qmlcompiler/qqmljsoptimizations.cpp
index 3fe2d89cf7..0603d6fa42 100644
--- a/src/qmlcompiler/qqmljsoptimizations.cpp
+++ b/src/qmlcompiler/qqmljsoptimizations.cpp
@@ -9,11 +9,9 @@ QT_BEGIN_NAMESPACE
using namespace Qt::Literals::StringLiterals;
-QQmlJSCompilePass::BlocksAndAnnotations QQmlJSOptimizations::run(const Function *function,
- QQmlJS::DiagnosticMessage *error)
+QQmlJSCompilePass::BlocksAndAnnotations QQmlJSOptimizations::run(const Function *function)
{
m_function = function;
- m_error = error;
populateBasicBlocks();
populateReaderLocations();
@@ -329,7 +327,7 @@ void QQmlJSOptimizations::adjustTypes()
return; // Constructed something else.
if (!m_typeResolver->adjustTrackedType(it->trackedTypes[0], it->typeReaders.values()))
- setError(adjustErrorMessage(it->trackedTypes[0], it->typeReaders.values()));
+ addError(adjustErrorMessage(it->trackedTypes[0], it->typeReaders.values()));
// Now we don't adjust the type we store, but rather the type we expect to read. We
// can do this because we've tracked the read type when we defined the array in
@@ -342,7 +340,7 @@ void QQmlJSOptimizations::adjustTypes()
if (mode != ObjectOrArrayDefinition::ArrayConstruct1ArgId
|| !m_typeResolver->equals(contained, m_typeResolver->realType())) {
if (!m_typeResolver->adjustTrackedType(contained, valueType))
- setError(adjustErrorMessage(contained, valueType));
+ addError(adjustErrorMessage(contained, valueType));
}
}
@@ -366,7 +364,7 @@ void QQmlJSOptimizations::adjustTypes()
Q_ASSERT(!annotation.readRegisters.isEmpty());
if (!m_typeResolver->adjustTrackedType(resultType, it->typeReaders.values()))
- setError(adjustErrorMessage(resultType, it->typeReaders.values()));
+ addError(adjustErrorMessage(resultType, it->typeReaders.values()));
if (m_typeResolver->equals(resultType, m_typeResolver->varType())
|| m_typeResolver->equals(resultType, m_typeResolver->variantMapType())) {
@@ -385,19 +383,19 @@ void QQmlJSOptimizations::adjustTypes()
const QString propName = m_jsUnitGenerator->jsClassMember(object.internalClassId, i);
const QQmlJSMetaProperty property = resultType->property(propName);
if (!property.isValid()) {
- setError(resultType->internalName() + QLatin1String(" has no property called ")
+ addError(resultType->internalName() + QLatin1String(" has no property called ")
+ propName);
continue;
}
const QQmlJSScope::ConstPtr propType = property.type();
if (propType.isNull()) {
- setError(QLatin1String("Cannot resolve type of property ") + propName);
+ addError(QLatin1String("Cannot resolve type of property ") + propName);
continue;
}
const QQmlJSRegisterContent content = annotation.readRegisters[object.argv + i].content;
const QQmlJSScope::ConstPtr contained = content.containedType();
if (!m_typeResolver->adjustTrackedType(contained, propType))
- setError(adjustErrorMessage(contained, propType));
+ addError(adjustErrorMessage(contained, propType));
}
// The others cannot be adjusted. We don't know their names, yet.
@@ -433,7 +431,7 @@ void QQmlJSOptimizations::adjustTypes()
continue;
if (!m_typeResolver->adjustTrackedType(it->trackedTypes[0], it->typeReaders.values()))
- setError(adjustErrorMessage(it->trackedTypes[0], it->typeReaders.values()));
+ addError(adjustErrorMessage(it->trackedTypes[0], it->typeReaders.values()));
}
@@ -453,7 +451,7 @@ void QQmlJSOptimizations::adjustTypes()
for (const auto &origin : conversionOrigins)
newResult = m_typeResolver->merge(newResult, origin);
if (!m_typeResolver->adjustTrackedType(conversionResult, newResult))
- setError(adjustErrorMessage(conversionResult, newResult));
+ addError(adjustErrorMessage(conversionResult, newResult));
}
newRegisters.appendOrdered(conversion);
}