Port to new Q_UNREACHABLE_RETURN()
This is a semantic patch using ClangTidyTransformator to convert
sequences of Q_UNREACHABLE() + return into Q_UNREACHABLE_RETURN(),
newly added to qtbase.
const std::string unr = "unr", val = "val", ret = "ret";
auto makeUnreachableReturn = cat("Q_UNREACHABLE_RETURN(",
ifBound(val, cat(node(val)), cat("")),
")");
auto ignoringSwitchCases = [](auto stmt) {
return anyOf(stmt, switchCase(subStmt(stmt)));
};
makeRule(stmt(ignoringSwitchCases(stmt(isExpandedFromMacro("Q_UNREACHABLE")).bind(unr)),
nextStmt(returnStmt(optionally(hasReturnValue(expr().bind(val)))).bind(ret))),
{changeTo(node(unr), cat(makeUnreachableReturn,
";")), // TODO: why is the ; lost w/o this?
changeTo(node(ret), cat(""))},
cat("use ", makeUnreachableReturn));
a.k.a qt-use-unreachable-return.
subStmt() and nextStmt() are non-standard matchers.
Change-Id: I3855b2dc8523db1ea860f72ad9818738162495c6
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Mike Krus <mike.krus@kdab.com>
| commit | e4343bcfe85111042a38870704079329cfe49794 |
| parent | be9ccff07db89d2b6470b5654b0244ee8699c150 |
| author | Marc Mutz <marc.mutz@qt.io> |
| committer | Marc Mutz <marc.mutz@qt.io> |
| commit time | Thu, 20 Oct 2022 10:37:45 +0200 |
- M src/animation/backend/clipblendvalue.cpp
- M src/core/transforms/matrix4x4_sse_p.h
- M src/core/transforms/vector3d_sse_p.h
- M src/core/transforms/vector4d_sse_p.h
- M src/input/backend/updateaxisactionjob.cpp
- M src/plugins/renderers/opengl/graphicshelpers/graphicshelperes2.cpp
- M src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl2.cpp
- M src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl3_2.cpp
- M src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl3_3.cpp
- M src/plugins/renderers/opengl/graphicshelpers/graphicshelpergl4.cpp
- M src/plugins/renderers/opengl/graphicshelpers/imagesubmissioncontext.cpp
- M src/plugins/renderers/opengl/graphicshelpers/submissioncontext.cpp
- M src/plugins/renderers/opengl/renderer/renderview.cpp
- M src/plugins/renderers/rhi/renderer/renderview.cpp
- M src/plugins/renderers/rhi/textures/texture.cpp
- M src/render/backend/entity_p.h
- M src/render/backend/pointsvisitor.cpp
- M src/render/backend/uniform.cpp
- M src/render/renderstates/renderstatenode.cpp