summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@qt.io>2022-10-08 19:56:03 +0200
committerMarc Mutz <marc.mutz@qt.io>2022-10-16 15:37:56 +0200
commit85039ca5cbc924b883195b6b02493bc7a5441d85 (patch)
treef5272120a47368eb98a689e756810c786e21842c /tests
parentf2d1df63b079ecbaa17d68fcd64d0a78a41a0a4d (diff)
Port from container::count() and length() to size() - V4
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"); a.k.a qt-port-to-std-compatible-api V4 with config Scope: 'Container'. Change-Id: Idbda176819f0ca2544d830ff084ae0bdd1977adf Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/postbuild/bic/qbic.cpp22
-rw-r--r--tests/postbuild/symbols/tst_symbols.cpp6
2 files changed, 14 insertions, 14 deletions
diff --git a/tests/postbuild/bic/qbic.cpp b/tests/postbuild/bic/qbic.cpp
index 68471dd5..9944add2 100644
--- a/tests/postbuild/bic/qbic.cpp
+++ b/tests/postbuild/bic/qbic.cpp
@@ -28,7 +28,7 @@ bool QBic::isBlacklisted(const QString &className) const
if (className.contains('<'))
return true;
- for (int i = 0; i < blackList.count(); ++i)
+ for (int i = 0; i < blackList.size(); ++i)
if (blackList[i].match(className).hasMatch())
return true;
return false;
@@ -38,7 +38,7 @@ static bool qualifiedTailMatch(const QString &expectedTail, const QString &symbo
{
if (symbol == expectedTail)
return true;
- const QString tail = symbol.right(expectedTail.length() - 2);
+ const QString tail = symbol.right(expectedTail.size() - 2);
if (!tail.startsWith(QLatin1String("::")))
return false;
return tail.endsWith(expectedTail);
@@ -46,8 +46,8 @@ static bool qualifiedTailMatch(const QString &expectedTail, const QString &symbo
static QString innerClassVTableSymbol(const QString &outerClass, const QString &innerClass)
{
- return (QLatin1String("_ZTVN") + QString::number(outerClass.length()) + outerClass
- + QString::number(innerClass.length()) + innerClass + QLatin1Char('E'));
+ return (QLatin1String("_ZTVN") + QString::number(outerClass.size()) + outerClass
+ + QString::number(innerClass.size()) + innerClass + QLatin1Char('E'));
}
static QStringList nonVirtualThunkToDestructorSymbols(const QString &className)
@@ -55,9 +55,9 @@ static QStringList nonVirtualThunkToDestructorSymbols(const QString &className)
const QString symbolTemplate = QString::fromLatin1("%1::_ZThn%2_N%3%4");
QStringList candidates;
- candidates << symbolTemplate.arg(className).arg(16).arg(className.length()).arg(className)
- << symbolTemplate.arg(className).arg(32).arg(className.length()).arg(className)
- << symbolTemplate.arg(className).arg(40).arg(className.length()).arg(className)
+ candidates << symbolTemplate.arg(className).arg(16).arg(className.size()).arg(className)
+ << symbolTemplate.arg(className).arg(32).arg(className.size()).arg(className)
+ << symbolTemplate.arg(className).arg(40).arg(className.size()).arg(className)
;
QStringList result;
@@ -117,7 +117,7 @@ static QStringList normalizedVTable(const QStringList &entry)
QString className = entry.at(1).section(QLatin1Char(' '), 0, 0);
className.chop(1);
- for (int i = 2; i < entry.count(); ++i) {
+ for (int i = 2; i < entry.size(); ++i) {
const QString line = entry.at(i).simplified();
bool isOk = false;
int num = line.left(line.indexOf(QLatin1Char(' '))).toInt(&isOk);
@@ -175,7 +175,7 @@ QBic::Info QBic::parseOutput(const QByteArray &ba) const
foreach(QString str, source) {
QStringList entry = str.split('\n');
- if (entry.count() < 2)
+ if (entry.size() < 2)
continue;
if (entry.at(0).startsWith("Class ")) {
const QString className = entry.at(0).mid(6);
@@ -242,13 +242,13 @@ QBic::VTableDiff QBic::diffVTables(const Info &oldLib, const Info &newLib) const
}
const QStringList oldVTable = oldLib.classVTables.value(it.key());
const QStringList vTable = it.value();
- if (vTable.count() != oldVTable.count()) {
+ if (vTable.size() != oldVTable.size()) {
result.modifiedVTables.append(QPair<QString, QString>(it.key(),
QLatin1String("size mismatch")));
continue;
}
- for (int i = 0; i < vTable.count(); ++i) {
+ for (int i = 0; i < vTable.size(); ++i) {
VTableDiffResult diffResult = diffVTableEntry(vTable.at(i), oldVTable.at(i));
switch (diffResult) {
case Match:
diff --git a/tests/postbuild/symbols/tst_symbols.cpp b/tests/postbuild/symbols/tst_symbols.cpp
index 08905d6a..475dd9d7 100644
--- a/tests/postbuild/symbols/tst_symbols.cpp
+++ b/tests/postbuild/symbols/tst_symbols.cpp
@@ -408,8 +408,8 @@ void tst_Symbols::prefix()
QStringList fields = symbol.split(' ');
// the last two fields are address and size and the third last field is the symbol type
- QVERIFY(fields.count() > 3);
- QString type = fields.at(fields.count() - 3);
+ QVERIFY(fields.size() > 3);
+ QString type = fields.at(fields.size() - 3);
// weak symbol
if (type == QLatin1String("W")) {
if (symbol.contains("qAtomic"))
@@ -431,7 +431,7 @@ void tst_Symbols::prefix()
continue;
QString plainSymbol;
- for (int i = 0; i < fields.count() - 3; ++i) {
+ for (int i = 0; i < fields.size() - 3; ++i) {
if (i > 0)
plainSymbol += QLatin1Char(' ');
plainSymbol += fields.at(i);