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-10 22:33:39 +0200 |
commit | 363f39ce63652fd67263e9b1db02c10da062912e (patch) | |
tree | 4e7d265ab427c1ef0adc1759464067f71b728a3b | |
parent | 6e351d5f45c82c0773b7d0731be370793bca30a5 (diff) | |
download | qtwebsockets-363f39ce63652fd67263e9b1db02c10da062912e.tar.gz |
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: I58e1b41b91c34d2e860dbb5847b3752edbfc6fc9
Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
-rw-r--r-- | tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp b/tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp index f8d4dba..cd568f3 100644 --- a/tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp +++ b/tests/auto/websockets/qwebsocketserver/tst_qwebsocketserver.cpp @@ -718,7 +718,7 @@ static void openManyConnections(QList<SocketSpy *> *sockets, quint16 port, int n static int sumSocketSpyCount(const QList<SocketSpy *> &sockets) { return std::accumulate(sockets.cbegin(), sockets.cend(), 0, [](int c, SocketSpy *s) { - return c + s->disconnectSpy->count(); + return c + s->disconnectSpy->size(); }); } |