1c6bf3e09e
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> |
||
---|---|---|
.. | ||
subdir | ||
task71021 | ||
Test.framework/Headers | ||
testproject | ||
.gitattributes | ||
.gitignore | ||
allmocs_baseline_in.json | ||
assign-namespace.h | ||
backslash-newlines.h | ||
c-comments.h | ||
CMakeLists.txt | ||
cstyle-enums.h | ||
cxx11-enums.h | ||
cxx11-explicit-override-control.h | ||
cxx11-final-classes.h | ||
cxx11-trailing-return.h | ||
cxx17-namespaces.h | ||
cxx-attributes.h | ||
dir-in-include-path.h | ||
dollars.h | ||
enum_inc.h | ||
enum_with_include.h | ||
error-on-wrong-notify.h | ||
escapes-in-string-literals.h | ||
extraqualification.h | ||
forgotten-qinterface.h | ||
forward-declared-param.h | ||
forwarddeclaredparam.h | ||
function-with-attributes.h | ||
fwdclass1.h | ||
fwdclass2.h | ||
fwdclass3.h | ||
gadgetwithnoenums.h | ||
grand-parent-gadget-class.h | ||
Header | ||
interface-from-framework.h | ||
interface-from-include.h | ||
macro-on-cmdline.h | ||
moc_include.h | ||
namespace_no_merge.h | ||
namespace.h | ||
namespaced-flags.h | ||
no-keywords.h | ||
non-gadget-parent-class.h | ||
oldstyle-casts.h | ||
os9-newlines.h | ||
parse-boost.h | ||
parse-defines.h | ||
plugin_metadata.h | ||
pointery_to_incomplete.h | ||
pp-dollar-signs.h | ||
pure-virtual-signals.h | ||
qinvokable.h | ||
qmlmacro.h | ||
qprivateslots.h | ||
qtbug-35657-gadget.h | ||
related-metaobjects-in-gadget.h | ||
related-metaobjects-in-namespaces.h | ||
related-metaobjects-name-conflict.h | ||
single_function_keyword.h | ||
single-quote-digit-separator-n3781.h | ||
slots-with-void-template.h | ||
task87883.h | ||
task192552.h | ||
task234909.h | ||
task240368.h | ||
template-gtgt.h | ||
trigraphs.h | ||
tst_moc.cpp | ||
unterminated-function-macro.h | ||
using-namespaces.h | ||
warn-on-multiple-qobject-subclasses.h | ||
warn-on-property-without-read.h | ||
win-newlines.h |