From 47ebd2ae5e40f5d1228edd3a35d0272dcf545585 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 13 Oct 2022 23:18:06 +0200 Subject: 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 Reviewed-by: Ivan Solovev --- src/client/qwaylandinputcontext.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/client/qwaylandinputcontext.cpp b/src/client/qwaylandinputcontext.cpp index cb94005b3..e67311a16 100644 --- a/src/client/qwaylandinputcontext.cpp +++ b/src/client/qwaylandinputcontext.cpp @@ -288,8 +288,7 @@ bool QWaylandInputContext::filterEvent(const QEvent *event) case XKB_COMPOSE_NOTHING: return false; default: - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } } -- cgit v1.2.3