Fix build-breaking warnings
Qt's asKeyValueRange of associative containers cannot return references to key/value pairs, so Apple's clang warns when using ranged-for with references to elements. Use a structured binding instead as the loop variable, and delay some conversions of QSet<QString> to QStringList until the list is needed. Change-Id: I37aa101e6d9cd008cde0c2db790132dc051a249b Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
This commit is contained in:
parent
bca463b61c
commit
761beaa354
|
@ -651,9 +651,9 @@ QQmlJSLinter::LintResult QQmlJSLinter::lintModule(const QString &module, const b
|
|||
const QString modulePrefix = u"$module$."_s;
|
||||
const QString internalPrefix = u"$internal$."_s;
|
||||
|
||||
for (const auto &kv : types.asKeyValueRange()) {
|
||||
QString name = kv.first;
|
||||
const QQmlJSScope::ConstPtr scope = kv.second.scope;
|
||||
for (auto &&[typeName, importedScope] : types.asKeyValueRange()) {
|
||||
QString name = typeName;
|
||||
const QQmlJSScope::ConstPtr scope = importedScope.scope;
|
||||
|
||||
if (name.startsWith(modulePrefix))
|
||||
continue;
|
||||
|
@ -723,26 +723,24 @@ QQmlJSLinter::LintResult QQmlJSLinter::lintModule(const QString &module, const b
|
|||
}
|
||||
}
|
||||
|
||||
for (const auto &kv : missingTypes.asKeyValueRange()) {
|
||||
const QString &name = kv.first;
|
||||
const QStringList uses = QStringList(kv.second.begin(), kv.second.end());
|
||||
|
||||
for (auto &&[name, uses] : missingTypes.asKeyValueRange()) {
|
||||
QString message = u"Type \"%1\" not found"_s.arg(name);
|
||||
|
||||
if (!uses.isEmpty())
|
||||
message += u". Used in %1"_s.arg(uses.join(u", "_s));
|
||||
if (!uses.isEmpty()) {
|
||||
const QStringList usesList = QStringList(uses.begin(), uses.end());
|
||||
message += u". Used in %1"_s.arg(usesList.join(u", "_s));
|
||||
}
|
||||
|
||||
m_logger->log(message, qmlUnresolvedType, QQmlJS::SourceLocation());
|
||||
}
|
||||
|
||||
for (const auto &kv : partiallyResolvedTypes.asKeyValueRange()) {
|
||||
const QString &name = kv.first;
|
||||
const QStringList uses = QStringList(kv.second.begin(), kv.second.end());
|
||||
|
||||
for (auto &&[name, uses] : partiallyResolvedTypes.asKeyValueRange()) {
|
||||
QString message = u"Type \"%1\" is not fully resolved"_s.arg(name);
|
||||
|
||||
if (!uses.isEmpty())
|
||||
message += u". Used in %1"_s.arg(uses.join(u", "_s));
|
||||
if (!uses.isEmpty()) {
|
||||
const QStringList usesList = QStringList(uses.begin(), uses.end());
|
||||
message += u". Used in %1"_s.arg(usesList.join(u", "_s));
|
||||
}
|
||||
|
||||
m_logger->log(message, qmlUnresolvedType, QQmlJS::SourceLocation());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue