diff options
author | Ahmad Samir <a.samirh78@gmail.com> | 2023-05-15 14:41:14 +0300 |
---|---|---|
committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-05-18 22:39:25 +0300 |
commit | 976c3615a336ddb75d4430ff78fa2d1c20b45db2 (patch) | |
tree | e163d06cd9373c80152422427a4ca864a8c9faef /src/tools/moc/preprocessor.cpp | |
parent | 5c7702a8f9c8cf3722945b643dc3d21303c2482c (diff) |
Moc: fix some narrowing conversion warnings by using range operations
I.e. range-for and in one case QList::append(iterator, iterator).
Drive-by changes:
- Check a QByteArray isn't empty before using at()
- Shorten a long line, QString::fromLocal8Bit() works with QByteArray
Pick-to: 6.5
Change-Id: I7e54ce39f65ccb1fe5e60693ac98e239b9f0d794
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'src/tools/moc/preprocessor.cpp')
-rw-r--r-- | src/tools/moc/preprocessor.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/src/tools/moc/preprocessor.cpp b/src/tools/moc/preprocessor.cpp index 0958e26be3..d5603696ae 100644 --- a/src/tools/moc/preprocessor.cpp +++ b/src/tools/moc/preprocessor.cpp @@ -649,9 +649,9 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym const Symbols &arg = arguments.at(index); QByteArray stringified; - for (int i = 0; i < arg.size(); ++i) { - stringified += arg.at(i).lexem(); - } + for (const Symbol &sym : arg) + stringified += sym.lexem(); + stringified.replace('"', "\\\""); stringified.prepend('"'); stringified.append('"'); @@ -685,8 +685,8 @@ Symbols Preprocessor::macroExpandIdentifier(Preprocessor *that, SymbolStack &sym if (index >= 0 && index < arguments.size()) { const Symbols &arg = arguments.at(index); - for (int i = 1; i < arg.size(); ++i) - expansion += arg.at(i); + if (!arg.isEmpty()) + expansion.append(arg.cbegin() + 1, arg.cend()); } } mode = Normal; @@ -1000,8 +1000,10 @@ static QByteArray searchIncludePaths(const QList<Parser::IncludePath> &includepa fprintf(stderr, "debug-includes: searching for '%s'\n", include.constData()); } - for (int j = 0; j < includepaths.size() && !fi.exists(); ++j) { - const Parser::IncludePath &p = includepaths.at(j); + for (const Parser::IncludePath &p : includepaths) { + if (fi.exists()) + break; + if (p.isFrameworkPath) { const int slashPos = include.indexOf('/'); if (slashPos == -1) |