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: I3b040fa72968753048fd669c073ae80c3ba1bdad
Reviewed-by: Mike Krus <mike.krus@kdab.com>
| commit | 201ca07ae23ab142ac2efcf2413adf6c243be7f7 |
| parent | e4343bcfe85111042a38870704079329cfe49794 |
| author | Marc Mutz <marc.mutz@qt.io> |
| committer | Marc Mutz <marc.mutz@qt.io> |
| commit time | Thu, 20 Oct 2022 12:49:12 +0200 |
- M src/animation/backend/animationutils.cpp
- M src/core/nodes/qentity.cpp
- M src/extras/defaults/qspritesheet.cpp
- M src/logic/manager.cpp
- M src/plugins/renderers/opengl/graphicshelpers/qgraphicsutils_p.h
- M src/plugins/renderers/opengl/renderer/commandexecuter.cpp
- M src/plugins/sceneparsers/gltf/gltfimporter.cpp
- M src/quick3d/quick3d/items/quick3dentity.cpp
- M src/quick3d/quick3d/items/quick3dgeometry.cpp
- M src/quick3d/quick3d/items/quick3djoint.cpp
- M src/quick3d/quick3d/items/quick3dnode.cpp
- M src/quick3d/quick3d/items/quick3dnodeinstantiator.cpp
- M src/quick3d/quick3d/qt3dquickvaluetypes.cpp
- M src/quick3d/quick3danimation/items/quick3danimationcontroller.cpp
- M src/quick3d/quick3danimation/items/quick3danimationgroup.cpp
- M src/quick3d/quick3danimation/items/quick3dkeyframeanimation.cpp
- M src/quick3d/quick3danimation/items/quick3dmorphinganimation.cpp
- M src/quick3d/quick3danimation/items/quick3dmorphtarget.cpp
- M src/quick3d/quick3danimation/items/quick3dvertexblendanimation.cpp
- M src/quick3d/quick3dextras/items/quick3dspritesheet.cpp
- M src/quick3d/quick3dinput/items/quick3daction.cpp
- M src/quick3d/quick3dinput/items/quick3daxis.cpp
- M src/quick3d/quick3dinput/items/quick3dinputchord.cpp
- M src/quick3d/quick3dinput/items/quick3dinputsequence.cpp
- M src/quick3d/quick3dinput/items/quick3dlogicaldevice.cpp
- M src/quick3d/quick3dinput/items/quick3dphysicaldevice.cpp
- M src/quick3d/quick3drender/items/quick3deffect.cpp
- M src/quick3d/quick3drender/items/quick3dlayerfilter.cpp
- M src/quick3d/quick3drender/items/quick3dmaterial.cpp
- M src/quick3d/quick3drender/items/quick3drenderpass.cpp
- M src/quick3d/quick3drender/items/quick3drenderpassfilter.cpp
- M src/quick3d/quick3drender/items/quick3drendertargetoutput.cpp
- M src/quick3d/quick3drender/items/quick3dshaderdataarray.cpp
- M src/quick3d/quick3drender/items/quick3dstateset.cpp
- M src/quick3d/quick3drender/items/quick3dtechnique.cpp
- M src/quick3d/quick3drender/items/quick3dtechniquefilter.cpp
- M src/quick3d/quick3drender/items/quick3dtexture.cpp
- M src/quick3d/quick3dscene2d/items/qt3dquick3dscene2d.cpp
- M src/render/framegraph/qframegraphnode.cpp
- M src/render/frontend/qrenderaspect.cpp
- M src/render/jobs/uniformblockbuilder.cpp
- M src/render/materialsystem/qshaderprogram.cpp
- M src/render/materialsystem/shaderdata.cpp
- M src/render/picking/qraycasterhit.cpp
- M src/render/shadergraph/qshadergenerator.cpp
- M src/render/texture/qtexture.cpp
- M tests/auto/animation/qabstractanimation/tst_qabstractanimation.cpp
- M tests/auto/animation/qadditiveclipblend/tst_qadditiveclipblend.cpp
- M tests/auto/animation/qanimationcliploader/tst_qanimationcliploader.cpp
- M tests/auto/animation/qanimationcontroller/tst_qanimationcontroller.cpp
- M tests/auto/animation/qanimationgroup/tst_qanimationgroup.cpp
- M tests/auto/animation/qblendedclipanimator/tst_qblendedclipanimator.cpp
- M tests/auto/animation/qcallbackmapping/tst_qcallbackmapping.cpp
- M tests/auto/animation/qchannelmapping/tst_qchannelmapping.cpp
- M tests/auto/animation/qclipanimator/tst_qclipanimator.cpp
- M tests/auto/animation/qclipblendvalue/tst_qclipblendvalue.cpp
- M tests/auto/animation/qclock/tst_qclock.cpp
- M tests/auto/animation/qkeyframeanimation/tst_qkeyframeanimation.cpp
- M tests/auto/animation/qlerpclipblend/tst_qlerpclipblend.cpp
- M tests/auto/animation/qmorphinganimation/tst_qmorphinganimation.cpp
- M tests/auto/animation/qskeletonmapping/tst_qskeletonmapping.cpp
- M tests/auto/animation/qvertexblendanimation/tst_qvertexblendanimation.cpp
- M tests/auto/core/nodes/tst_nodes.cpp
- M tests/auto/core/qjoint/tst_qjoint.cpp
- M tests/auto/core/qscene/tst_qscene.cpp
- M tests/auto/core/qskeletonloader/tst_qskeletonloader.cpp
- M tests/auto/core/qtransform/tst_qtransform.cpp
- M tests/auto/extras/qtext2dentity/tst_qtext2dentity.cpp
- M tests/auto/input/axisaccumulator/tst_axisaccumulator.cpp
- M tests/auto/input/loadproxydevicejob/tst_loadproxydevicejob.cpp
- M tests/auto/input/qmousedevice/tst_qmousedevice.cpp
- M tests/auto/quick3d/quick3dnodeinstantiator/stringmodel.h
- M tests/auto/quick3d/quick3dnodeinstantiator/tst_quick3dnodeinstantiator.cpp
- M tests/auto/render/entity/tst_entity.cpp
- M tests/auto/render/framegraphnode/tst_framegraphnode.cpp
- M tests/auto/render/geometry/tst_geometry.cpp
- M tests/auto/render/geometryloaders/tst_geometryloaders.cpp
- M tests/auto/render/material/tst_material.cpp
- M tests/auto/render/opengl/renderviewutils/tst_renderviewutils.cpp
- M tests/auto/render/pickboundingvolumejob/tst_pickboundingvolumejob.cpp
- M tests/auto/render/qabstracttexture/tst_qabstracttexture.cpp
- M tests/auto/render/qabstracttextureimage/tst_qabstracttextureimage.cpp
- M tests/auto/render/qcameralens/tst_qcameralens.cpp
- M tests/auto/render/qcomputecommand/tst_qcomputecommand.cpp
- M tests/auto/render/qdispatchcompute/tst_qdispatchcompute.cpp
- M tests/auto/render/qenvironmentlight/tst_qenvironmentlight.cpp
- M tests/auto/render/qfilterkey/tst_qfilterkey.cpp
- M tests/auto/render/qgeometry/tst_qgeometry.cpp
- M tests/auto/render/qgraphicsapifilter/tst_qgraphicsapifilter.cpp
- M tests/auto/render/qmemorybarrier/tst_qmemorybarrier.cpp
- M tests/auto/render/qmesh/tst_qmesh.cpp
- M tests/auto/render/qparameter/tst_qparameter.cpp
- M tests/auto/render/qproximityfilter/tst_qproximityfilter.cpp
- M tests/auto/render/qraycaster/tst_qraycaster.cpp
- M tests/auto/render/qrenderpass/tst_qrenderpass.cpp
- M tests/auto/render/qrenderpassfilter/tst_qrenderpassfilter.cpp
- M tests/auto/render/qrendersettings/tst_qrendersettings.cpp
- M tests/auto/render/qrendersurfaceselector/tst_qrendersurfaceselector.cpp
- M tests/auto/render/qrendertargetoutput/tst_qrendertargetoutput.cpp
- M tests/auto/render/qscene2d/tst_qscene2d.cpp
- M tests/auto/render/qsetfence/tst_qsetfence.cpp
- M tests/auto/render/qshaderimage/tst_qshaderimage.cpp
- M tests/auto/render/qshaderprogram/tst_qshaderprogram.cpp
- M tests/auto/render/qshaderprogrambuilder/tst_qshaderprogrambuilder.cpp
- M tests/auto/render/qsharedgltexture/tst_qsharedgltexture.cpp
- M tests/auto/render/qtechnique/tst_qtechnique.cpp
- M tests/auto/render/qtechniquefilter/tst_qtechniquefilter.cpp
- M tests/auto/render/qtextureimage/tst_qtextureimage.cpp
- M tests/auto/render/qtextureloader/tst_qtextureloader.cpp
- M tests/auto/render/qwaitfence/tst_qwaitfence.cpp
- M tests/auto/render/raycastingjob/tst_raycastingjob.cpp
- M tests/auto/render/shaderbuilder/tst_shaderbuilder.cpp