diff options
author | Marc Mutz <marc.mutz@qt.io> | 2022-10-08 19:56:03 +0200 |
---|---|---|
committer | Marc Mutz <marc.mutz@qt.io> | 2022-10-13 00:18:35 +0200 |
commit | 5eb52b725526c26d0efa3856b6aba1919010f8fd (patch) | |
tree | 64d1bde7a2cc624e586228c9768c7eb1ea360e6c /tools | |
parent | e1a0596924766d62459740ed0271114a7bb99851 (diff) |
Port from container::count() and length() to size() - V5
This is a semantic patch using ClangTidyTransformator as in
qtbase/df9d882d41b741fef7c5beeddb0abe9d904443d8, but extended to
handle typedefs and accesses through pointers, too:
const std::string o = "object";
auto hasTypeIgnoringPointer = [](auto type) { return anyOf(hasType(type), hasType(pointsTo(type))); };
auto derivedFromAnyOfClasses = [&](ArrayRef<StringRef> classes) {
auto exprOfDeclaredType = [&](auto decl) {
return expr(hasTypeIgnoringPointer(hasUnqualifiedDesugaredType(recordType(hasDeclaration(decl))))).bind(o);
};
return exprOfDeclaredType(cxxRecordDecl(isSameOrDerivedFrom(hasAnyName(classes))));
};
auto renameMethod = [&] (ArrayRef<StringRef> classes,
StringRef from, StringRef to) {
return makeRule(cxxMemberCallExpr(on(derivedFromAnyOfClasses(classes)),
callee(cxxMethodDecl(hasName(from), parameterCountIs(0)))),
changeTo(cat(access(o, cat(to)), "()")),
cat("use '", to, "' instead of '", from, "'"));
};
renameMethod(<classes>, "count", "size");
renameMethod(<classes>, "length", "size");
except that on() was replaced with a matcher that doesn't ignoreParens().
a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'.
Change-Id: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qmlimportscanner/main.cpp | 4 | ||||
-rw-r--r-- | tools/qmlplugindump/main.cpp | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp index b36591d1fd..7c8f1bc98e 100644 --- a/tools/qmlimportscanner/main.cpp +++ b/tools/qmlimportscanner/main.cpp @@ -475,7 +475,7 @@ QVariantList getGetDetailedModuleImportsIncludingDependencies( std::unordered_set<QVariant, ImportVariantHasher> importsSeen; importsToProcess.append(inputImport); - for (int i = 0; i < importsToProcess.length(); ++i) { + for (int i = 0; i < importsToProcess.size(); ++i) { const QVariant importToProcess = importsToProcess.at(i); auto [details, deps] = getImportDetails(importToProcess, fileImportsWithoutDepsCache); if (details.value(typeLiteral()) == moduleLiteral()) { @@ -674,7 +674,7 @@ QVariantList findQmlImportsInFile(const QString &filePath, const auto pathsTimeEnd = QDateTime::currentDateTime(); const auto duration = pathsTimeBegin.msecsTo(pathsTimeEnd); const auto fileProcessingDuration = fileProcessTimeBegin.msecsTo(pathsTimeEnd); - qCDebug(lcImportScanner) << "Found module paths:" << importPaths.count() + qCDebug(lcImportScanner) << "Found module paths:" << importPaths.size() << "TS:" << pathsTimeEnd.toMSecsSinceEpoch() << "Path resolution duration:" << duration << "msecs"; qCDebug(lcImportScanner) << "Scan duration:" << fileProcessingDuration << "msecs"; diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp index dac28320f6..81245232b7 100644 --- a/tools/qmlplugindump/main.cpp +++ b/tools/qmlplugindump/main.cpp @@ -629,11 +629,11 @@ private: if (typeName->endsWith('*')) { *isPointer = true; - typeName->truncate(typeName->length() - 1); + typeName->truncate(typeName->size() - 1); removePointerAndList(typeName, isList, isPointer); } else if (typeName->startsWith(declListPrefix)) { *isList = true; - typeName->truncate(typeName->length() - 1); // get rid of the suffix '>' + typeName->truncate(typeName->size() - 1); // get rid of the suffix '>' *typeName = typeName->mid(declListPrefix.size()); removePointerAndList(typeName, isList, isPointer); } |