qt5base-lts/tests/auto/tools/moc
Marc Mutz 1c6bf3e09e 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 the on() matcher has been replaced by one that doesn't
ignoreParens().

a.k.a qt-port-to-std-compatible-api V5 with config Scope: 'Container'.

Added two NOLINTNEXTLINEs in tst_qbitarray and tst_qcontiguouscache,
to avoid porting calls that explicitly test count().

Change-Id: Icfb8808c2ff4a30187e9935a51cad26987451c22
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2022-11-03 14:59:24 +01:00
..
subdir moc: get the system #defines from the compiler itself 2016-07-20 02:54:03 +00:00
task71021
Test.framework/Headers Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
testproject Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
.gitattributes
.gitignore Add support for machine-readable JSON output to the MOC 2019-10-04 18:35:29 +02:00
allmocs_baseline_in.json QMetaType: fix void* parameters 2022-08-01 14:52:22 -07:00
assign-namespace.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
backslash-newlines.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
c-comments.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
CMakeLists.txt Change the license of all CMakeLists.txt and *.cmake files to BSD 2022-08-23 23:58:42 +02:00
cstyle-enums.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
cxx11-enums.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
cxx11-explicit-override-control.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
cxx11-final-classes.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
cxx11-trailing-return.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
cxx17-namespaces.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
cxx-attributes.h moc: handle attributes in class declarations 2022-08-03 20:14:42 +02:00
dir-in-include-path.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
dollars.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
enum_inc.h moc: Handle include in enum, take 2 2020-11-03 19:36:34 +00:00
enum_with_include.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
error-on-wrong-notify.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
escapes-in-string-literals.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
extraqualification.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
forgotten-qinterface.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
forward-declared-param.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
forwarddeclaredparam.h MetaObject: Store the QMetaType of the methods 2020-06-02 22:42:15 +02:00
function-with-attributes.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
fwdclass1.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
fwdclass2.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
fwdclass3.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
gadgetwithnoenums.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
grand-parent-gadget-class.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
Header
interface-from-framework.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
interface-from-include.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
macro-on-cmdline.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
moc_include.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
namespace_no_merge.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
namespace.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
namespaced-flags.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
no-keywords.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
non-gadget-parent-class.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
oldstyle-casts.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
os9-newlines.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
parse-boost.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
parse-defines.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
plugin_metadata.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
pointery_to_incomplete.h QMetaType: fix void* parameters 2022-08-01 14:52:22 -07:00
pp-dollar-signs.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
pure-virtual-signals.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qinvokable.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qmlmacro.h moc: Do not fail to compile meta-methods containing non-const ref types 2022-09-21 18:41:43 +00:00
qprivateslots.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
qtbug-35657-gadget.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
related-metaobjects-in-gadget.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
related-metaobjects-in-namespaces.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
related-metaobjects-name-conflict.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
single_function_keyword.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
single-quote-digit-separator-n3781.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
slots-with-void-template.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
task87883.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
task192552.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
task234909.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
task240368.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
template-gtgt.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
trigraphs.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
tst_moc.cpp Port from container::count() and length() to size() - V5 2022-11-03 14:59:24 +01:00
unterminated-function-macro.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
using-namespaces.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
warn-on-multiple-qobject-subclasses.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
warn-on-property-without-read.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00
win-newlines.h Use SPDX license identifiers 2022-05-16 16:37:38 +02:00