From fc7676769251a27cbbc6d40d68f04bfe38511a5b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 22 Sep 2022 11:39:44 +0200 Subject: Long live Q_UNREACHABLE_RETURN()! This is a combination of Q_UNREACHABLE() with a return statement. ATM, the return statement is unconditionally included. If we notice that some compilers warn about return after __builtin_unreachable(), then we can map Q_UNREACHABLE_RETURN(...) to Q_UNREACHABLE() without having to touch all the code that uses explicit Q_UNREACHABLE() + return. The fact that Boost has BOOST_UNREACHABLE_RETURN() indicates that there are compilers that complain about a lack of return after Q_UNREACHABLE (we know that MSVC, ICC, and GHS are among them), as well as compilers that complained about a return being present (Coverity). Take this opportunity to properly adapt to Coverity, by leaving out the return statement on this compiler. Apply the macro around the code base, using a clang-tidy transformer rule: 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)) ); where nextStmt() is copied from some upstream clang-tidy check's private implementation and subStmt() is a private matcher that gives access to SwitchCase's SubStmt. A.k.a. qt-use-unreachable-return. There were some false positives, suppressed them with NOLINTNEXTLINE. They're not really false positiives, it's just that Clang sees the world in one way and if conditonal compilation (#if) differs for other compilers, Clang doesn't know better. This is an artifact of matching two consecutive statements. I haven't figured out how to remove the empty line left by the deletion of the return statement, if it, indeed, was on a separate line, so post-processed the patch to remove all the lines matching ^\+ *$ from the diff: git commit -am meep git reset --hard HEAD^ git diff HEAD..HEAD@{1} | sed '/^\+ *$/d' | recountdiff - | patch -p1 [ChangeLog][QtCore][QtAssert] Added Q_UNREACHABLE_RETURN() macro. Change-Id: I9782939f16091c964f25b7826e1c0dbd13a71305 Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- .../snippets/code/src_corelib_global_qglobal.cpp | 13 +++++ src/corelib/global/qassert.cpp | 20 +++++++- src/corelib/global/qassert.h | 8 +++ src/corelib/global/qcompilerdetection.h | 1 + src/corelib/global/qcompilerdetection.qdoc | 2 +- src/corelib/io/qprocess.cpp | 3 +- src/corelib/io/qurl.cpp | 6 +-- src/corelib/kernel/qmetatype.cpp | 3 +- src/corelib/kernel/qpropertyprivate.h | 3 +- src/corelib/kernel/qvariant.cpp | 6 +-- src/corelib/serialization/qcborstreamreader.cpp | 6 +-- src/corelib/serialization/qcborstreamwriter.cpp | 6 +-- src/corelib/serialization/qjsoncbor.cpp | 3 +- src/corelib/serialization/qjsonvalue.cpp | 3 +- src/corelib/text/qbytearray.cpp | 6 +-- src/corelib/text/qlocale_tools.cpp | 3 +- src/corelib/text/qstring.cpp | 3 +- src/corelib/text/qstringalgorithms_p.h | 3 +- src/corelib/thread/qfutex_p.h | 2 +- src/corelib/time/qdatetime.cpp | 6 +-- src/corelib/time/qdatetimeparser.cpp | 6 +-- src/corelib/tools/qatomicscopedvaluerollback_p.h | 1 + src/corelib/tools/qfreelist_p.h | 3 +- src/corelib/tools/qhash.cpp | 1 + src/gui/image/qimage_conversions.cpp | 3 +- src/gui/kernel/qshortcutmap.cpp | 3 +- src/gui/painting/qdrawhelper.cpp | 6 +-- src/gui/painting/qpixellayout.cpp | 3 +- src/gui/painting/webgradients.cpp | 3 +- src/gui/rhi/qrhi.cpp | 24 +++------ src/gui/rhi/qrhigles2.cpp | 51 +++++++------------ src/gui/rhi/qrhinull.cpp | 3 +- src/gui/rhi/qrhivulkan.cpp | 57 ++++++++-------------- src/gui/text/qtextdocumentlayout.cpp | 12 ++--- src/gui/text/qtextengine.cpp | 3 +- src/network/access/http2/hpacktable.cpp | 3 +- src/network/ssl/qssldiffiehellmanparameters.cpp | 3 +- src/network/ssl/qtlsbackend.cpp | 6 +-- src/opengl/qopenglframebufferobject.cpp | 3 +- src/opengl/qopengltexture.cpp | 15 ++---- .../qnetworkmanagernetworkinformationbackend.cpp | 3 +- .../compose/qcomposeplatforminputcontext.cpp | 3 +- .../platforms/linuxfb/qlinuxfbdrmscreen.cpp | 3 +- src/printsupport/kernel/qcups.cpp | 6 +-- src/testlib/qabstracttestlogger.cpp | 3 +- src/testlib/qplaintestlogger.cpp | 6 +-- src/testlib/qtestcase.cpp | 3 +- src/testlib/qtestresult.cpp | 6 +-- src/tools/moc/generator.cpp | 3 +- src/widgets/dialogs/qinputdialog.cpp | 3 +- src/widgets/dialogs/qwizard.cpp | 6 +-- src/widgets/itemviews/qheaderview.cpp | 3 +- .../auto/corelib/global/qtendian/tst_qtendian.cpp | 6 +-- tests/auto/other/qobjectrace/tst_qobjectrace.cpp | 3 +- .../tst_bench_qcryptographichash.cpp | 3 +- 55 files changed, 154 insertions(+), 221 deletions(-) diff --git a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp index 4d6f566bf8..096e36dc72 100644 --- a/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_global_qglobal.cpp @@ -667,6 +667,19 @@ bool readConfiguration(const QFile &file) } //! [qunreachable-switch] +//! [qunreachable-return] + switch (shape) { + case Rectangle: + return rectangle(); + case Triangle: + return triangle(); + case Circle: + return circle(); + case NumShapes: + Q_UNREACHABLE_RETURN(nullptr); + } +//! [qunreachable-return] + //! [qt-version-check] #include diff --git a/src/corelib/global/qassert.cpp b/src/corelib/global/qassert.cpp index 2e340ebbb2..4165429d4b 100644 --- a/src/corelib/global/qassert.cpp +++ b/src/corelib/global/qassert.cpp @@ -195,7 +195,25 @@ void qBadAlloc() In debug builds the condition is enforced by an assert to facilitate debugging. - \sa Q_ASSERT(), Q_ASSUME(), qFatal() + \note Use the macro Q_UNREACHABLE_RETURN() to insert return statements for + compilers that need them, without causing warnings for compilers that + complain about its presence. + + \sa Q_ASSERT(), Q_ASSUME(), qFatal(), Q_UNREACHABLE_RETURN() */ +/*! + \macro void Q_UNREACHABLE_RETURN(...) + \relates + \since 6.5 + + This is equivalent to + \code + Q_UNREACHABLE(); + return __VA_ARGS__; + \endcode + except it omits the return on compilers that would warn about it. + + \sa Q_UNREACHABLE() +*/ QT_END_NAMESPACE diff --git a/src/corelib/global/qassert.h b/src/corelib/global/qassert.h index c7ee13176a..28c6b6c8fc 100644 --- a/src/corelib/global/qassert.h +++ b/src/corelib/global/qassert.h @@ -70,6 +70,14 @@ inline T *q_check_ptr(T *p) { Q_CHECK_PTR(p); return p; } Q_UNREACHABLE_IMPL();\ } while (false) +#ifndef Q_UNREACHABLE_RETURN +# ifdef Q_COMPILER_COMPLAINS_ABOUT_RETURN_AFTER_UNREACHABLE +# define Q_UNREACHABLE_RETURN(...) Q_UNREACHABLE() +# else +# define Q_UNREACHABLE_RETURN(...) do { Q_UNREACHABLE(); return __VA_ARGS__; } while (0) +# endif +#endif + #define Q_ASSUME(Expr) \ [] (bool valueOfExpression) {\ Q_ASSERT_X(valueOfExpression, "Q_ASSUME()", "Assumption in Q_ASSUME(\"" #Expr "\") was not correct");\ diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 6dd76ce30a..35d0c5816b 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -49,6 +49,7 @@ #if defined(__COVERITY__) # define Q_CC_COVERITY +# define Q_COMPILER_COMPLAINS_ABOUT_RETURN_AFTER_UNREACHABLE #endif /* Symantec C++ is now Digital Mars */ diff --git a/src/corelib/global/qcompilerdetection.qdoc b/src/corelib/global/qcompilerdetection.qdoc index 05a4b89f1d..377323a5eb 100644 --- a/src/corelib/global/qcompilerdetection.qdoc +++ b/src/corelib/global/qcompilerdetection.qdoc @@ -180,7 +180,7 @@ This is useful since a missing break statement is often a bug, and some compilers can be configured to emit warnings when one is not found. - \sa Q_UNREACHABLE() + \sa Q_UNREACHABLE(), Q_UNREACHABLE_RETURN() */ /*! diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index c838b665b7..1af592d39d 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1903,8 +1903,7 @@ void QProcess::setProcessState(ProcessState state) */ auto QProcess::setupChildProcess() -> Use_setChildProcessModifier_Instead { - Q_UNREACHABLE(); - return {}; + Q_UNREACHABLE_RETURN({}); } #endif diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 3cebb68561..591ed7fe87 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -3495,8 +3495,7 @@ static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &err case QUrlPrivate::NoError: Q_ASSERT_X(false, "QUrl::errorString", "Impossible: QUrl::errorString should have treated this condition"); - Q_UNREACHABLE(); - return QString(); + Q_UNREACHABLE_RETURN(QString()); case QUrlPrivate::InvalidSchemeError: { auto msg = "Invalid scheme (character '%1' not permitted)"_L1; @@ -3554,8 +3553,7 @@ static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &err } Q_ASSERT_X(false, "QUrl::errorString", "Cannot happen, unknown error"); - Q_UNREACHABLE(); - return QString(); + Q_UNREACHABLE_RETURN(QString()); } static inline void appendComponentIfPresent(QString &msg, bool present, const char *componentName, diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 5ad7967605..1047c8c0aa 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -2006,8 +2006,7 @@ static bool convertToEnum(QMetaType fromType, const void *from, QMetaType toType *static_cast(to) = value; return true; default: - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } } diff --git a/src/corelib/kernel/qpropertyprivate.h b/src/corelib/kernel/qpropertyprivate.h index 966821fa67..4387f0fbeb 100644 --- a/src/corelib/kernel/qpropertyprivate.h +++ b/src/corelib/kernel/qpropertyprivate.h @@ -194,8 +194,7 @@ struct BindingFunctionVTable return true; } else { // Our code will never instantiate this - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } }, /*destroy*/[](void *f){ static_cast(f)->~Callable(); }, diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index 5e949487db..3fb80f203e 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -2261,8 +2261,7 @@ static bool integralEquals(uint promotedType, const QVariant::Private *d1, const if (promotedType == QMetaType::ULongLong) return qulonglong(l1) == qulonglong(l2); - Q_UNREACHABLE(); - return 0; + Q_UNREACHABLE_RETURN(0); } namespace { @@ -2306,8 +2305,7 @@ static std::optional integralCompare(uint promotedType, const QVariant::Pri if (promotedType == QMetaType::ULongLong) return spaceShip(l1, l2); - Q_UNREACHABLE(); - return 0; + Q_UNREACHABLE_RETURN(0); } static std::optional numericCompare(const QVariant::Private *d1, const QVariant::Private *d2) diff --git a/src/corelib/serialization/qcborstreamreader.cpp b/src/corelib/serialization/qcborstreamreader.cpp index 5f6c0feb49..86fb1f0d7e 100644 --- a/src/corelib/serialization/qcborstreamreader.cpp +++ b/src/corelib/serialization/qcborstreamreader.cpp @@ -36,13 +36,11 @@ QT_WARNING_POP static CborError _cbor_value_dup_string(const CborValue *, void **, size_t *, CborValue *) { - Q_UNREACHABLE(); - return CborErrorInternalError; + Q_UNREACHABLE_RETURN(CborErrorInternalError); } [[maybe_unused]] static CborError cbor_value_get_half_float_as_float(const CborValue *, float *) { - Q_UNREACHABLE(); - return CborErrorInternalError; + Q_UNREACHABLE_RETURN(CborErrorInternalError); } // confirm our constants match TinyCBOR's diff --git a/src/corelib/serialization/qcborstreamwriter.cpp b/src/corelib/serialization/qcborstreamwriter.cpp index 0e445451bc..a2ddc15161 100644 --- a/src/corelib/serialization/qcborstreamwriter.cpp +++ b/src/corelib/serialization/qcborstreamwriter.cpp @@ -29,14 +29,12 @@ QT_WARNING_POP // but never defined [[maybe_unused]] static CborError cbor_encoder_close_container_checked(CborEncoder*, const CborEncoder*) { - Q_UNREACHABLE(); - return CborErrorInternalError; + Q_UNREACHABLE_RETURN(CborErrorInternalError); } [[maybe_unused]] static CborError cbor_encode_float_as_half_float(CborEncoder *, float) { - Q_UNREACHABLE(); - return CborErrorInternalError; + Q_UNREACHABLE_RETURN(CborErrorInternalError); } Q_DECLARE_TYPEINFO(CborEncoder, Q_PRIMITIVE_TYPE); diff --git a/src/corelib/serialization/qjsoncbor.cpp b/src/corelib/serialization/qjsoncbor.cpp index 67db3d7d6c..ad0e95061c 100644 --- a/src/corelib/serialization/qjsoncbor.cpp +++ b/src/corelib/serialization/qjsoncbor.cpp @@ -576,8 +576,7 @@ QVariant QCborValue::toVariant() const if (isSimpleType()) return QVariant::fromValue(toSimpleType()); - Q_UNREACHABLE(); - return QVariant(); + Q_UNREACHABLE_RETURN(QVariant()); } /*! diff --git a/src/corelib/serialization/qjsonvalue.cpp b/src/corelib/serialization/qjsonvalue.cpp index 5383addb70..49fc0d85d1 100644 --- a/src/corelib/serialization/qjsonvalue.cpp +++ b/src/corelib/serialization/qjsonvalue.cpp @@ -1097,8 +1097,7 @@ size_t qHash(const QJsonValue &value, size_t seed) case QJsonValue::Undefined: return seed; } - Q_UNREACHABLE(); - return 0; + Q_UNREACHABLE_RETURN(0); } #if !defined(QT_NO_DEBUG_STREAM) && !defined(QT_JSON_READONLY) diff --git a/src/corelib/text/qbytearray.cpp b/src/corelib/text/qbytearray.cpp index 33292d9ca2..29728fcf51 100644 --- a/src/corelib/text/qbytearray.cpp +++ b/src/corelib/text/qbytearray.cpp @@ -541,8 +541,7 @@ static const char *zlibOpAsString(ZLibOp op) case ZLibOp::Compression: return "qCompress"; case ZLibOp::Decompression: return "qUncompress"; } - Q_UNREACHABLE(); - return nullptr; + Q_UNREACHABLE_RETURN(nullptr); } Q_DECL_COLD_FUNCTION @@ -2908,8 +2907,7 @@ QByteArray QByteArray::mid(qsizetype pos, qsizetype len) const case QContainerImplHelper::Subset: return QByteArray(d.data() + p, l); } - Q_UNREACHABLE(); - return QByteArray(); + Q_UNREACHABLE_RETURN(QByteArray()); } /*! diff --git a/src/corelib/text/qlocale_tools.cpp b/src/corelib/text/qlocale_tools.cpp index ca6f954bed..f3e664ea41 100644 --- a/src/corelib/text/qlocale_tools.cpp +++ b/src/corelib/text/qlocale_tools.cpp @@ -570,8 +570,7 @@ QString qulltoa(qulonglong number, int base, const QStringView zero) number /= base; } } else { // zero should always be either a non-surrogate or a surrogate pair: - Q_UNREACHABLE(); - return QString(); + Q_UNREACHABLE_RETURN(QString()); } return QString(reinterpret_cast(p), end - p); diff --git a/src/corelib/text/qstring.cpp b/src/corelib/text/qstring.cpp index e77ff3f3d0..394e1d2c89 100644 --- a/src/corelib/text/qstring.cpp +++ b/src/corelib/text/qstring.cpp @@ -5025,8 +5025,7 @@ QString QString::mid(qsizetype position, qsizetype n) const case QContainerImplHelper::Subset: return QString(constData() + p, l); } - Q_UNREACHABLE(); - return QString(); + Q_UNREACHABLE_RETURN(QString()); } /*! diff --git a/src/corelib/text/qstringalgorithms_p.h b/src/corelib/text/qstringalgorithms_p.h index 513e2b8cbc..0b8118a858 100644 --- a/src/corelib/text/qstringalgorithms_p.h +++ b/src/corelib/text/qstringalgorithms_p.h @@ -47,8 +47,7 @@ template struct QStringAlgorithms static inline StringType trimmed_helper_inplace(const NakedStringType &, const Char *, const Char *) { // can't happen - Q_UNREACHABLE(); - return StringType(); + Q_UNREACHABLE_RETURN(StringType()); } static inline void trimmed_helper_positions(const Char *&begin, const Char *&end) diff --git a/src/corelib/thread/qfutex_p.h b/src/corelib/thread/qfutex_p.h index 9363cc02de..48f03f5ed0 100644 --- a/src/corelib/thread/qfutex_p.h +++ b/src/corelib/thread/qfutex_p.h @@ -24,7 +24,7 @@ namespace QtDummyFutex { constexpr inline bool futexAvailable() { return false; } template inline bool futexWait(Atomic &, typename Atomic::Type, int = 0) - { Q_UNREACHABLE(); return false; } + { Q_UNREACHABLE_RETURN(false); } template inline void futexWakeOne(Atomic &) { Q_UNREACHABLE(); } template inline void futexWakeAll(Atomic &) diff --git a/src/corelib/time/qdatetime.cpp b/src/corelib/time/qdatetime.cpp index 46a33d55c7..21f252a70d 100644 --- a/src/corelib/time/qdatetime.cpp +++ b/src/corelib/time/qdatetime.cpp @@ -2841,8 +2841,7 @@ static inline bool usesSameOffset(const QDateTimeData &a, const QDateTimeData &b Q_ASSERT(!a.isShort() && !b.isShort()); return a->m_offsetFromUtc == b->m_offsetFromUtc; } - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } // Refresh the LocalTime or TimeZone validity and offset @@ -3805,8 +3804,7 @@ qint64 QDateTime::toMSecsSinceEpoch() const #endif return 0; } - Q_UNREACHABLE(); - return 0; + Q_UNREACHABLE_RETURN(0); } /*! diff --git a/src/corelib/time/qdatetimeparser.cpp b/src/corelib/time/qdatetimeparser.cpp index a90fb46046..ab784912e5 100644 --- a/src/corelib/time/qdatetimeparser.cpp +++ b/src/corelib/time/qdatetimeparser.cpp @@ -1441,8 +1441,7 @@ QDateTimeParser::scanString(const QDateTime &defaultValue, bool fixup) const // Don't care about date or spec, so pick a safe spec: return StateNode(QDateTime(date, time, Qt::UTC), state, padding, conflicts); default: - Q_UNREACHABLE(); - return StateNode(); + Q_UNREACHABLE_RETURN(StateNode()); } } @@ -2253,8 +2252,7 @@ QString QDateTimeParser::getAmPmText(AmPm ap, Case cs) const case LowerCase: return raw.toLower(); case NativeCase: return raw; } - Q_UNREACHABLE(); - return raw; + Q_UNREACHABLE_RETURN(raw); } /* diff --git a/src/corelib/tools/qatomicscopedvaluerollback_p.h b/src/corelib/tools/qatomicscopedvaluerollback_p.h index a0f088ec45..147156d585 100644 --- a/src/corelib/tools/qatomicscopedvaluerollback_p.h +++ b/src/corelib/tools/qatomicscopedvaluerollback_p.h @@ -43,6 +43,7 @@ class [[nodiscard]] QAtomicScopedValueRollback } // GCC 8.x does not tread __builtin_unreachable() as constexpr #if !defined(Q_CC_GNU_ONLY) || (Q_CC_GNU >= 900) + // NOLINTNEXTLINE(qt-use-unreachable-return): Triggers on Clang, breaking GCC 8 Q_UNREACHABLE(); #endif return std::memory_order_seq_cst; diff --git a/src/corelib/tools/qfreelist_p.h b/src/corelib/tools/qfreelist_p.h index c06c569d23..6bbde5b4b6 100644 --- a/src/corelib/tools/qfreelist_p.h +++ b/src/corelib/tools/qfreelist_p.h @@ -124,8 +124,7 @@ class QFreeList return i; x -= size; } - Q_UNREACHABLE(); - return -1; + Q_UNREACHABLE_RETURN(-1); } // allocate a block of the given \a size, initialized starting with the given \a offset diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp index 9b69c79389..bac2a01afc 100644 --- a/src/corelib/tools/qhash.cpp +++ b/src/corelib/tools/qhash.cpp @@ -107,6 +107,7 @@ private: StateResult result = { 0, OverriddenByEnvironment }; #ifdef QT_BOOTSTRAPPED Q_UNUSED(which); + // NOLINTNEXTLINE(qt-use-unreachable-return): triggers on QT_BOOTSTRAPPED, breaking #else case Q_UNREACHABLE(); #else // can't use qEnvironmentVariableIntValue (reentrancy) diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index fa75bed3c8..d13bef7190 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -1033,8 +1033,7 @@ static inline uint qUnpremultiplyRgb30(uint rgb30) case 3: return rgb30; } - Q_UNREACHABLE(); - return 0; + Q_UNREACHABLE_RETURN(0); } template diff --git a/src/gui/kernel/qshortcutmap.cpp b/src/gui/kernel/qshortcutmap.cpp index e3236a0086..ed03f00542 100644 --- a/src/gui/kernel/qshortcutmap.cpp +++ b/src/gui/kernel/qshortcutmap.cpp @@ -313,8 +313,7 @@ bool QShortcutMap::tryShortcut(QKeyEvent *e) return identicalMatches > 0; } } - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } /*! \internal diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 35c44b8286..e5d322e1dc 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -50,8 +50,7 @@ constexpr int half_point = 1 << 15; template static inline uint QT_FASTCALL fetch1Pixel(const uchar *, int) { - Q_UNREACHABLE(); - return 0; + Q_UNREACHABLE_RETURN(0); } template <> @@ -4917,8 +4916,7 @@ void qBlendTexture(int count, const QSpan *spans, void *userData) ProcessSpans proc; switch (data->rasterBuffer->format) { case QImage::Format_Invalid: - Q_UNREACHABLE(); - return; + Q_UNREACHABLE_RETURN(); case QImage::Format_ARGB32_Premultiplied: proc = processTextureSpansARGB32PM[blendType]; break; diff --git a/src/gui/painting/qpixellayout.cpp b/src/gui/painting/qpixellayout.cpp index 025bb168f5..871fd1014d 100644 --- a/src/gui/painting/qpixellayout.cpp +++ b/src/gui/painting/qpixellayout.cpp @@ -212,8 +212,7 @@ inline void QT_FASTCALL storePixel(uchar *dest, int index, template static inline uint QT_FASTCALL fetchPixel(const uchar *, int) { - Q_UNREACHABLE(); - return 0; + Q_UNREACHABLE_RETURN(0); } template <> diff --git a/src/gui/painting/webgradients.cpp b/src/gui/painting/webgradients.cpp index 5924fe6e60..fd5031349e 100644 --- a/src/gui/painting/webgradients.cpp +++ b/src/gui/painting/webgradients.cpp @@ -346,8 +346,7 @@ static QList qt_preset_gradient_stops(QGradient::Preset preset) case QGradient::NumPresets: Q_UNREACHABLE(); } - Q_UNREACHABLE(); - return {}; + Q_UNREACHABLE_RETURN({}); } static constexpr QGradient::QGradientData qt_preset_gradient_data[] = { diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 3821062c8e..a52b953a37 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -1435,8 +1435,7 @@ QRhiVertexInputAttribute::Format QRhiImplementation::shaderDescVariableFormatToV return QRhiVertexInputAttribute::UInt; default: - Q_UNREACHABLE(); - return QRhiVertexInputAttribute::Float; + Q_UNREACHABLE_RETURN(QRhiVertexInputAttribute::Float); } } @@ -1478,8 +1477,7 @@ quint32 QRhiImplementation::byteSizePerVertexForVertexInputFormat(QRhiVertexInpu return sizeof(qint32); default: - Q_UNREACHABLE(); - return 1; + Q_UNREACHABLE_RETURN(1); } } @@ -4120,8 +4118,7 @@ bool operator==(const QRhiShaderResourceBinding &a, const QRhiShaderResourceBind } break; default: - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } return true; @@ -5100,8 +5097,7 @@ static const char *resourceTypeStr(QRhiResource *res) return "CommandBuffer"; } - Q_UNREACHABLE(); - return ""; + Q_UNREACHABLE_RETURN(""); } QRhiImplementation::~QRhiImplementation() @@ -5629,8 +5625,7 @@ const char *QRhi::backendName(Implementation impl) return "Metal"; } - Q_UNREACHABLE(); - return "Unknown"; + Q_UNREACHABLE_RETURN("Unknown"); } /*! @@ -5691,8 +5686,7 @@ static inline const char *deviceTypeStr(QRhiDriverInfo::DeviceType type) return "Cpu"; } - Q_UNREACHABLE(); - return nullptr; + Q_UNREACHABLE_RETURN(nullptr); } QDebug operator<<(QDebug dbg, const QRhiDriverInfo &info) { @@ -7768,8 +7762,7 @@ QRhiPassResourceTracker::BufferStage QRhiPassResourceTracker::toPassTrackerBuffe if (stages.testFlag(QRhiShaderResourceBinding::GeometryStage)) return QRhiPassResourceTracker::BufGeometryStage; - Q_UNREACHABLE(); - return QRhiPassResourceTracker::BufVertexStage; + Q_UNREACHABLE_RETURN(QRhiPassResourceTracker::BufVertexStage); } QRhiPassResourceTracker::TextureStage QRhiPassResourceTracker::toPassTrackerTextureStage(QRhiShaderResourceBinding::StageFlags stages) @@ -7788,8 +7781,7 @@ QRhiPassResourceTracker::TextureStage QRhiPassResourceTracker::toPassTrackerText if (stages.testFlag(QRhiShaderResourceBinding::GeometryStage)) return QRhiPassResourceTracker::TexGeometryStage; - Q_UNREACHABLE(); - return QRhiPassResourceTracker::TexVertexStage; + Q_UNREACHABLE_RETURN(QRhiPassResourceTracker::TexVertexStage); } QT_END_NAMESPACE diff --git a/src/gui/rhi/qrhigles2.cpp b/src/gui/rhi/qrhigles2.cpp index a45915495e..a8b7919647 100644 --- a/src/gui/rhi/qrhigles2.cpp +++ b/src/gui/rhi/qrhigles2.cpp @@ -1232,8 +1232,7 @@ bool QRhiGles2::isFeatureSupported(QRhi::Feature feature) const case QRhi::NonFillPolygonMode: return !caps.gles; default: - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } } @@ -1271,8 +1270,7 @@ int QRhiGles2::resourceLimit(QRhi::ResourceLimit limit) const case QRhi::MaxVertexOutputs: return caps.maxVertexOutputs; default: - Q_UNREACHABLE(); - return 0; + Q_UNREACHABLE_RETURN(0); } } @@ -2356,8 +2354,7 @@ static inline GLenum toGlTopology(QRhiGraphicsPipeline::Topology t) case QRhiGraphicsPipeline::Patches: return GL_PATCHES; default: - Q_UNREACHABLE(); - return GL_TRIANGLES; + Q_UNREACHABLE_RETURN(GL_TRIANGLES); } } @@ -2369,8 +2366,7 @@ static inline GLenum toGlCullMode(QRhiGraphicsPipeline::CullMode c) case QRhiGraphicsPipeline::Back: return GL_BACK; default: - Q_UNREACHABLE(); - return GL_BACK; + Q_UNREACHABLE_RETURN(GL_BACK); } } @@ -2382,8 +2378,7 @@ static inline GLenum toGlFrontFace(QRhiGraphicsPipeline::FrontFace f) case QRhiGraphicsPipeline::CW: return GL_CW; default: - Q_UNREACHABLE(); - return GL_CCW; + Q_UNREACHABLE_RETURN(GL_CCW); } } @@ -2427,8 +2422,7 @@ static inline GLenum toGlBlendFactor(QRhiGraphicsPipeline::BlendFactor f) qWarning("Unsupported blend factor %d", f); return GL_ZERO; default: - Q_UNREACHABLE(); - return GL_ZERO; + Q_UNREACHABLE_RETURN(GL_ZERO); } } @@ -2446,8 +2440,7 @@ static inline GLenum toGlBlendOp(QRhiGraphicsPipeline::BlendOp op) case QRhiGraphicsPipeline::Max: return GL_MAX; default: - Q_UNREACHABLE(); - return GL_FUNC_ADD; + Q_UNREACHABLE_RETURN(GL_FUNC_ADD); } } @@ -2471,8 +2464,7 @@ static inline GLenum toGlCompareOp(QRhiGraphicsPipeline::CompareOp op) case QRhiGraphicsPipeline::Always: return GL_ALWAYS; default: - Q_UNREACHABLE(); - return GL_ALWAYS; + Q_UNREACHABLE_RETURN(GL_ALWAYS); } } @@ -2496,8 +2488,7 @@ static inline GLenum toGlStencilOp(QRhiGraphicsPipeline::StencilOp op) case QRhiGraphicsPipeline::DecrementAndWrap: return GL_DECR_WRAP; default: - Q_UNREACHABLE(); - return GL_KEEP; + Q_UNREACHABLE_RETURN(GL_KEEP); } } @@ -2509,8 +2500,7 @@ static inline GLenum toGlPolygonMode(QRhiGraphicsPipeline::PolygonMode mode) case QRhiGraphicsPipeline::PolygonMode::Line: return GL_LINE; default: - Q_UNREACHABLE(); - return GL_FILL; + Q_UNREACHABLE_RETURN(GL_FILL); } } @@ -2528,8 +2518,7 @@ static inline GLenum toGlMinFilter(QRhiSampler::Filter f, QRhiSampler::Filter m) else return m == QRhiSampler::Nearest ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR_MIPMAP_LINEAR; default: - Q_UNREACHABLE(); - return GL_LINEAR; + Q_UNREACHABLE_RETURN(GL_LINEAR); } } @@ -2541,8 +2530,7 @@ static inline GLenum toGlMagFilter(QRhiSampler::Filter f) case QRhiSampler::Linear: return GL_LINEAR; default: - Q_UNREACHABLE(); - return GL_LINEAR; + Q_UNREACHABLE_RETURN(GL_LINEAR); } } @@ -2556,8 +2544,7 @@ static inline GLenum toGlWrapMode(QRhiSampler::AddressMode m) case QRhiSampler::Mirror: return GL_MIRRORED_REPEAT; default: - Q_UNREACHABLE(); - return GL_CLAMP_TO_EDGE; + Q_UNREACHABLE_RETURN(GL_CLAMP_TO_EDGE); } } @@ -2581,8 +2568,7 @@ static inline GLenum toGlTextureCompareFunc(QRhiSampler::CompareOp op) case QRhiSampler::Always: return GL_ALWAYS; default: - Q_UNREACHABLE(); - return GL_NEVER; + Q_UNREACHABLE_RETURN(GL_NEVER); } } @@ -4275,8 +4261,7 @@ static inline GLenum toGlShaderType(QRhiShaderStage::Type type) case QRhiShaderStage::Compute: return GL_COMPUTE_SHADER; default: - Q_UNREACHABLE(); - return GL_VERTEX_SHADER; + Q_UNREACHABLE_RETURN(GL_VERTEX_SHADER); } } @@ -4558,8 +4543,7 @@ static inline QShader::Stage toShaderStage(QRhiShaderStage::Type type) case QRhiShaderStage::Compute: return QShader::ComputeStage; default: - Q_UNREACHABLE(); - return QShader::VertexStage; + Q_UNREACHABLE_RETURN(QShader::VertexStage); } } @@ -5526,8 +5510,7 @@ bool QGles2GraphicsPipeline::create() default: break; } - Q_UNREACHABLE(); - return VtxIdx; + Q_UNREACHABLE_RETURN(VtxIdx); }; QShaderDescription desc[LastIdx]; QShader::SeparateToCombinedImageSamplerMappingList samplerMappingList[LastIdx]; diff --git a/src/gui/rhi/qrhinull.cpp b/src/gui/rhi/qrhinull.cpp index b0c3c559c4..88afb004f7 100644 --- a/src/gui/rhi/qrhinull.cpp +++ b/src/gui/rhi/qrhinull.cpp @@ -135,8 +135,7 @@ int QRhiNull::resourceLimit(QRhi::ResourceLimit limit) const return 32; } - Q_UNREACHABLE(); - return 0; + Q_UNREACHABLE_RETURN(0); } const QRhiNativeHandles *QRhiNull::nativeHandles() diff --git a/src/gui/rhi/qrhivulkan.cpp b/src/gui/rhi/qrhivulkan.cpp index daf934f1d3..a04b9e8e0a 100644 --- a/src/gui/rhi/qrhivulkan.cpp +++ b/src/gui/rhi/qrhivulkan.cpp @@ -1016,8 +1016,7 @@ static inline VkFormat toVkTextureFormat(QRhiTexture::Format format, QRhiTexture return srgb ? VK_FORMAT_ASTC_12x12_SRGB_BLOCK : VK_FORMAT_ASTC_12x12_UNORM_BLOCK; default: - Q_UNREACHABLE(); - return VK_FORMAT_R8G8B8A8_UNORM; + Q_UNREACHABLE_RETURN(VK_FORMAT_R8G8B8A8_UNORM); } } @@ -3813,8 +3812,7 @@ VkSampleCountFlagBits QRhiVulkan::effectiveSampleCount(int sampleCount) return qvk_sampleCount.mask; } - Q_UNREACHABLE(); - return VK_SAMPLE_COUNT_1_BIT; + Q_UNREACHABLE_RETURN(VK_SAMPLE_COUNT_1_BIT); } void QRhiVulkan::enqueueTransitionPassResources(QVkCommandBuffer *cbD) @@ -4336,8 +4334,7 @@ bool QRhiVulkan::isFeatureSupported(QRhi::Feature feature) const case QRhi::NonFillPolygonMode: return caps.nonFillPolygonMode; default: - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } } @@ -4375,8 +4372,7 @@ int QRhiVulkan::resourceLimit(QRhi::ResourceLimit limit) const case QRhi::MaxVertexOutputs: return physDevProperties.limits.maxVertexOutputComponents / 4; default: - Q_UNREACHABLE(); - return 0; + Q_UNREACHABLE_RETURN(0); } } @@ -5258,8 +5254,7 @@ static inline VkFilter toVkFilter(QRhiSampler::Filter f) case QRhiSampler::Linear: return VK_FILTER_LINEAR; default: - Q_UNREACHABLE(); - return VK_FILTER_NEAREST; + Q_UNREACHABLE_RETURN(VK_FILTER_NEAREST); } } @@ -5273,8 +5268,7 @@ static inline VkSamplerMipmapMode toVkMipmapMode(QRhiSampler::Filter f) case QRhiSampler::Linear: return VK_SAMPLER_MIPMAP_MODE_LINEAR; default: - Q_UNREACHABLE(); - return VK_SAMPLER_MIPMAP_MODE_NEAREST; + Q_UNREACHABLE_RETURN(VK_SAMPLER_MIPMAP_MODE_NEAREST); } } @@ -5288,8 +5282,7 @@ static inline VkSamplerAddressMode toVkAddressMode(QRhiSampler::AddressMode m) case QRhiSampler::Mirror: return VK_SAMPLER_ADDRESS_MODE_MIRRORED_REPEAT; default: - Q_UNREACHABLE(); - return VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE; + Q_UNREACHABLE_RETURN(VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE); } } @@ -5309,8 +5302,7 @@ static inline VkShaderStageFlagBits toVkShaderStage(QRhiShaderStage::Type type) case QRhiShaderStage::Geometry: return VK_SHADER_STAGE_GEOMETRY_BIT; default: - Q_UNREACHABLE(); - return VK_SHADER_STAGE_VERTEX_BIT; + Q_UNREACHABLE_RETURN(VK_SHADER_STAGE_VERTEX_BIT); } } @@ -5348,8 +5340,7 @@ static inline VkFormat toVkAttributeFormat(QRhiVertexInputAttribute::Format form case QRhiVertexInputAttribute::SInt: return VK_FORMAT_R32_SINT; default: - Q_UNREACHABLE(); - return VK_FORMAT_R32G32B32A32_SFLOAT; + Q_UNREACHABLE_RETURN(VK_FORMAT_R32G32B32A32_SFLOAT); } } @@ -5371,8 +5362,7 @@ static inline VkPrimitiveTopology toVkTopology(QRhiGraphicsPipeline::Topology t) case QRhiGraphicsPipeline::Patches: return VK_PRIMITIVE_TOPOLOGY_PATCH_LIST; default: - Q_UNREACHABLE(); - return VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + Q_UNREACHABLE_RETURN(VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST); } } @@ -5386,8 +5376,7 @@ static inline VkCullModeFlags toVkCullMode(QRhiGraphicsPipeline::CullMode c) case QRhiGraphicsPipeline::Back: return VK_CULL_MODE_BACK_BIT; default: - Q_UNREACHABLE(); - return VK_CULL_MODE_NONE; + Q_UNREACHABLE_RETURN(VK_CULL_MODE_NONE); } } @@ -5399,8 +5388,7 @@ static inline VkFrontFace toVkFrontFace(QRhiGraphicsPipeline::FrontFace f) case QRhiGraphicsPipeline::CW: return VK_FRONT_FACE_CLOCKWISE; default: - Q_UNREACHABLE(); - return VK_FRONT_FACE_COUNTER_CLOCKWISE; + Q_UNREACHABLE_RETURN(VK_FRONT_FACE_COUNTER_CLOCKWISE); } } @@ -5460,8 +5448,7 @@ static inline VkBlendFactor toVkBlendFactor(QRhiGraphicsPipeline::BlendFactor f) case QRhiGraphicsPipeline::OneMinusSrc1Alpha: return VK_BLEND_FACTOR_ONE_MINUS_SRC1_ALPHA; default: - Q_UNREACHABLE(); - return VK_BLEND_FACTOR_ZERO; + Q_UNREACHABLE_RETURN(VK_BLEND_FACTOR_ZERO); } } @@ -5479,8 +5466,7 @@ static inline VkBlendOp toVkBlendOp(QRhiGraphicsPipeline::BlendOp op) case QRhiGraphicsPipeline::Max: return VK_BLEND_OP_MAX; default: - Q_UNREACHABLE(); - return VK_BLEND_OP_ADD; + Q_UNREACHABLE_RETURN(VK_BLEND_OP_ADD); } } @@ -5504,8 +5490,7 @@ static inline VkCompareOp toVkCompareOp(QRhiGraphicsPipeline::CompareOp op) case QRhiGraphicsPipeline::Always: return VK_COMPARE_OP_ALWAYS; default: - Q_UNREACHABLE(); - return VK_COMPARE_OP_ALWAYS; + Q_UNREACHABLE_RETURN(VK_COMPARE_OP_ALWAYS); } } @@ -5529,8 +5514,7 @@ static inline VkStencilOp toVkStencilOp(QRhiGraphicsPipeline::StencilOp op) case QRhiGraphicsPipeline::DecrementAndWrap: return VK_STENCIL_OP_DECREMENT_AND_WRAP; default: - Q_UNREACHABLE(); - return VK_STENCIL_OP_KEEP; + Q_UNREACHABLE_RETURN(VK_STENCIL_OP_KEEP); } } @@ -5542,8 +5526,7 @@ static inline VkPolygonMode toVkPolygonMode(QRhiGraphicsPipeline::PolygonMode mo case QRhiGraphicsPipeline::Line: return VK_POLYGON_MODE_LINE; default: - Q_UNREACHABLE(); - return VK_POLYGON_MODE_FILL; + Q_UNREACHABLE_RETURN(VK_POLYGON_MODE_FILL); } } @@ -5582,8 +5565,7 @@ static inline VkDescriptorType toVkDescriptorType(const QRhiShaderResourceBindin return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER; default: - Q_UNREACHABLE(); - return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; + Q_UNREACHABLE_RETURN(VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER); } } @@ -5625,8 +5607,7 @@ static inline VkCompareOp toVkTextureCompareOp(QRhiSampler::CompareOp op) case QRhiSampler::Always: return VK_COMPARE_OP_ALWAYS; default: - Q_UNREACHABLE(); - return VK_COMPARE_OP_NEVER; + Q_UNREACHABLE_RETURN(VK_COMPARE_OP_NEVER); } } diff --git a/src/gui/text/qtextdocumentlayout.cpp b/src/gui/text/qtextdocumentlayout.cpp index c95ec4c686..b86b6ca923 100644 --- a/src/gui/text/qtextdocumentlayout.cpp +++ b/src/gui/text/qtextdocumentlayout.cpp @@ -1209,8 +1209,7 @@ static inline QTextFormat::Property borderPropertyForEdge(QCss::Edge edge) case QCss::RightEdge: return QTextFormat::TableCellRightBorder; default: - Q_UNREACHABLE(); - return QTextFormat::UserProperty; + Q_UNREACHABLE_RETURN(QTextFormat::UserProperty); } } @@ -1226,8 +1225,7 @@ static inline QTextFormat::Property borderStylePropertyForEdge(QCss::Edge edge) case QCss::RightEdge: return QTextFormat::TableCellRightBorderStyle; default: - Q_UNREACHABLE(); - return QTextFormat::UserProperty; + Q_UNREACHABLE_RETURN(QTextFormat::UserProperty); } } @@ -1243,8 +1241,7 @@ static inline QCss::Edge adjacentEdge(QCss::Edge edge) case QCss::LeftEdge: return QCss::RightEdge; default: - Q_UNREACHABLE(); - return QCss::NumEdges; + Q_UNREACHABLE_RETURN(QCss::NumEdges); } } @@ -1323,8 +1320,7 @@ static inline bool sharesAxis(const QTextTableCell &cell, QCss::Edge edge, return cell.column() + cell.columnSpan() == competingCell.column() + (competingCellEdge == QCss::LeftEdge ? 0 : competingCell.columnSpan()); default: - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } } diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 1c1da979c8..27284d8d5a 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1395,8 +1395,7 @@ void QTextEngine::shapeText(int item) const } if (Q_UNLIKELY(!ensureSpace(itemLength))) { - Q_UNREACHABLE(); // ### report OOM error somehow - return; + Q_UNREACHABLE_RETURN(); // ### report OOM error somehow } QFontEngine *fontEngine = this->fontEngine(si, &si.ascent, &si.descent, &si.leading); diff --git a/src/network/access/http2/hpacktable.cpp b/src/network/access/http2/hpacktable.cpp index 0b69ee86a9..74a09a207f 100644 --- a/src/network/access/http2/hpacktable.cpp +++ b/src/network/access/http2/hpacktable.cpp @@ -346,8 +346,7 @@ quint32 FieldLookupTable::indexOfChunk(const Chunk *chunk) const return quint32(i); } - Q_UNREACHABLE(); - return 0; + Q_UNREACHABLE_RETURN(0); } quint32 FieldLookupTable::keyToIndex(const SearchEntry &key) const diff --git a/src/network/ssl/qssldiffiehellmanparameters.cpp b/src/network/ssl/qssldiffiehellmanparameters.cpp index 04add93116..b2c112bbf9 100644 --- a/src/network/ssl/qssldiffiehellmanparameters.cpp +++ b/src/network/ssl/qssldiffiehellmanparameters.cpp @@ -241,8 +241,7 @@ QString QSslDiffieHellmanParameters::errorString() const noexcept return QCoreApplication::translate("QSslDiffieHellmanParameter", "The given Diffie-Hellman parameters are deemed unsafe"); } - Q_UNREACHABLE(); - return QString(); + Q_UNREACHABLE_RETURN(QString()); } /*! diff --git a/src/network/ssl/qtlsbackend.cpp b/src/network/ssl/qtlsbackend.cpp index bc5b492d0f..d1157e5838 100644 --- a/src/network/ssl/qtlsbackend.cpp +++ b/src/network/ssl/qtlsbackend.cpp @@ -1382,8 +1382,7 @@ QByteArray TlsKey::pemHeader() const else if (algorithm() == QSsl::Dh) return QByteArrayLiteral("-----BEGIN PRIVATE KEY-----"); - Q_UNREACHABLE(); - return {}; + Q_UNREACHABLE_RETURN({}); } /*! @@ -1404,8 +1403,7 @@ QByteArray TlsKey::pemFooter() const else if (algorithm() == QSsl::Dh) return QByteArrayLiteral("-----END PRIVATE KEY-----"); - Q_UNREACHABLE(); - return {}; + Q_UNREACHABLE_RETURN({}); } /*! diff --git a/src/opengl/qopenglframebufferobject.cpp b/src/opengl/qopenglframebufferobject.cpp index 9aa89350ec..64b07e661f 100644 --- a/src/opengl/qopenglframebufferobject.cpp +++ b/src/opengl/qopenglframebufferobject.cpp @@ -1414,8 +1414,7 @@ static QImage qt_gl_read_framebuffer(const QSize &size, GLenum internal_format, return qt_gl_read_framebuffer_rgba8(size, include_alpha, ctx).mirrored(false, flip); } - Q_UNREACHABLE(); - return QImage(); + Q_UNREACHABLE_RETURN(QImage()); } Q_OPENGL_EXPORT QImage qt_gl_read_framebuffer(const QSize &size, bool alpha_format, bool include_alpha) diff --git a/src/opengl/qopengltexture.cpp b/src/opengl/qopengltexture.cpp index 8dc30cca61..6700f0e383 100644 --- a/src/opengl/qopengltexture.cpp +++ b/src/opengl/qopengltexture.cpp @@ -431,8 +431,7 @@ static bool isSizedTextureFormat(QOpenGLTexture::TextureFormat internalFormat) return false; } - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } static bool isTextureTargetMultisample(QOpenGLTexture::Target target) @@ -456,8 +455,7 @@ static bool isTextureTargetMultisample(QOpenGLTexture::Target target) return false; } - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } bool QOpenGLTexturePrivate::isUsingImmutableStorage() const @@ -756,8 +754,7 @@ static QOpenGLTexture::PixelFormat pixelFormatCompatibleWithInternalFormat(QOpen return QOpenGLTexture::LuminanceAlpha; } - Q_UNREACHABLE(); - return QOpenGLTexture::NoSourceFormat; + Q_UNREACHABLE_RETURN(QOpenGLTexture::NoSourceFormat); } static QOpenGLTexture::PixelType pixelTypeCompatibleWithInternalFormat(QOpenGLTexture::TextureFormat internalFormat) @@ -936,8 +933,7 @@ static QOpenGLTexture::PixelType pixelTypeCompatibleWithInternalFormat(QOpenGLTe return QOpenGLTexture::UInt8; } - Q_UNREACHABLE(); - return QOpenGLTexture::NoPixelType; + Q_UNREACHABLE_RETURN(QOpenGLTexture::NoPixelType); } static bool isCompressedFormat(QOpenGLTexture::TextureFormat internalFormat) @@ -1080,8 +1076,7 @@ static bool isCompressedFormat(QOpenGLTexture::TextureFormat internalFormat) return false; } - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } void QOpenGLTexturePrivate::allocateMutableStorage(QOpenGLTexture::PixelFormat pixelFormat, QOpenGLTexture::PixelType pixelType) diff --git a/src/plugins/networkinformation/networkmanager/qnetworkmanagernetworkinformationbackend.cpp b/src/plugins/networkinformation/networkmanager/qnetworkmanagernetworkinformationbackend.cpp index 67129af2de..6ee84e06f8 100644 --- a/src/plugins/networkinformation/networkmanager/qnetworkmanagernetworkinformationbackend.cpp +++ b/src/plugins/networkinformation/networkmanager/qnetworkmanagernetworkinformationbackend.cpp @@ -94,8 +94,7 @@ bool isMeteredFromNMMetered(QNetworkManagerInterface::NMMetered metered) case QNetworkManagerInterface::NM_METERED_UNKNOWN: return false; } - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } } // unnamed namespace diff --git a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp index 7e66e5fae8..3e74189076 100644 --- a/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp +++ b/src/plugins/platforminputcontexts/compose/qcomposeplatforminputcontext.cpp @@ -108,8 +108,7 @@ bool QComposeInputContext::filterEvent(const QEvent *event) case XKB_COMPOSE_NOTHING: return false; default: - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } } diff --git a/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp index 9cb232e13d..56b28ba48c 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp @@ -125,8 +125,7 @@ void QLinuxFbDevice::close() void *QLinuxFbDevice::nativeDisplay() const { - Q_UNREACHABLE(); - return nullptr; + Q_UNREACHABLE_RETURN(nullptr); } QPlatformScreen *QLinuxFbDevice::createScreen(const QKmsOutput &output) diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp index 5d1d4e5c98..f4d3263f48 100644 --- a/src/printsupport/kernel/qcups.cpp +++ b/src/printsupport/kernel/qcups.cpp @@ -89,8 +89,7 @@ static inline QString jobHoldToString(const QCUPSSupport::JobHoldUntil jobHold, case QCUPSSupport::NoHold: return QString(); } - Q_UNREACHABLE(); - return QString(); + Q_UNREACHABLE_RETURN(QString()); } QCUPSSupport::JobHoldUntilWithTime QCUPSSupport::parseJobHoldUntil(const QString &jobHoldUntil) @@ -176,8 +175,7 @@ static inline QString bannerPageToString(const QCUPSSupport::BannerPage bannerPa case QCUPSSupport::Secret: return QStringLiteral("secret"); case QCUPSSupport::TopSecret: return QStringLiteral("topsecret"); } - Q_UNREACHABLE(); - return QString(); + Q_UNREACHABLE_RETURN(QString()); } static inline QCUPSSupport::BannerPage stringToBannerPage(const QString &bannerPage) diff --git a/src/testlib/qabstracttestlogger.cpp b/src/testlib/qabstracttestlogger.cpp index d329386745..08fdade90b 100644 --- a/src/testlib/qabstracttestlogger.cpp +++ b/src/testlib/qabstracttestlogger.cpp @@ -351,8 +351,7 @@ void QAbstractTestLogger::addMessage(QtMsgType type, const QMessageLogContext &c case QtWarningMsg: return QAbstractTestLogger::QWarning; case QtFatalMsg: return QAbstractTestLogger::QFatal; } - Q_UNREACHABLE(); - return QAbstractTestLogger::QFatal; + Q_UNREACHABLE_RETURN(QAbstractTestLogger::QFatal); }(); QString formattedMessage = qFormatLogMessage(type, context, message); diff --git a/src/testlib/qplaintestlogger.cpp b/src/testlib/qplaintestlogger.cpp index 75443c96dc..dd5282cdb1 100644 --- a/src/testlib/qplaintestlogger.cpp +++ b/src/testlib/qplaintestlogger.cpp @@ -62,8 +62,7 @@ namespace QTest { case QAbstractTestLogger::BlacklistedXFail: return "BXFAIL "; } - Q_UNREACHABLE(); - return nullptr; + Q_UNREACHABLE_RETURN(nullptr); } static const char *benchmarkResult2String() @@ -89,8 +88,7 @@ namespace QTest { case QAbstractTestLogger::Warn: return "WARNING"; } - Q_UNREACHABLE(); - return nullptr; + Q_UNREACHABLE_RETURN(nullptr); } template diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index d3858267bc..cd8b6edeb7 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1230,8 +1230,7 @@ class WatchDog : public QThread waitCondition.wait(m, expectationChanged); return true; } - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } public: diff --git a/src/testlib/qtestresult.cpp b/src/testlib/qtestresult.cpp index 556cafd4d4..00799a02da 100644 --- a/src/testlib/qtestresult.cpp +++ b/src/testlib/qtestresult.cpp @@ -599,8 +599,7 @@ static const char *macroNameForOp(QTest::ComparisonOperation op) case ComparisonOperation::GreaterThanOrEqual: return "QCOMPARE_GE"; } - Q_UNREACHABLE(); - return ""; + Q_UNREACHABLE_RETURN(""); } static const char *failureMessageForOp(QTest::ComparisonOperation op) @@ -622,8 +621,7 @@ static const char *failureMessageForOp(QTest::ComparisonOperation op) case ComparisonOperation::GreaterThanOrEqual: return "Left value is expected to be greater than or equal to right value, but is not"; } - Q_UNREACHABLE(); - return ""; + Q_UNREACHABLE_RETURN(""); } bool QTestResult::reportResult(bool success, qxp::function_ref lhs, diff --git a/src/tools/moc/generator.cpp b/src/tools/moc/generator.cpp index d111380b8f..4c8a73043c 100644 --- a/src/tools/moc/generator.cpp +++ b/src/tools/moc/generator.cpp @@ -1554,8 +1554,7 @@ static CborError jsonValueToCbor(CborEncoder *parent, const QJsonValue &v) return cbor_encode_double(parent, d); } } - Q_UNREACHABLE(); - return CborUnknownError; + Q_UNREACHABLE_RETURN(CborUnknownError); } void Generator::generatePluginMetaData() diff --git a/src/widgets/dialogs/qinputdialog.cpp b/src/widgets/dialogs/qinputdialog.cpp index 80e329bcfe..89ea6e6746 100644 --- a/src/widgets/dialogs/qinputdialog.cpp +++ b/src/widgets/dialogs/qinputdialog.cpp @@ -38,8 +38,7 @@ static const char *candidateSignal(int which) case NumCandidateSignals: break; }; - Q_UNREACHABLE(); - return nullptr; + Q_UNREACHABLE_RETURN(nullptr); } static const char *signalForMember(const char *member) diff --git a/src/widgets/dialogs/qwizard.cpp b/src/widgets/dialogs/qwizard.cpp index 884517d53f..1716d8182b 100644 --- a/src/widgets/dialogs/qwizard.cpp +++ b/src/widgets/dialogs/qwizard.cpp @@ -129,8 +129,7 @@ static const char *changed_signal(int which) case 6: return SIGNAL(valueChanged(int)); }; static_assert(7 == NFallbackDefaultProperties); - Q_UNREACHABLE(); - return nullptr; + Q_UNREACHABLE_RETURN(nullptr); } class QWizardDefaultProperty @@ -1350,8 +1349,7 @@ static QString object_name_for_button(QWizard::WizardButton which) //case QWizard::NButtons: ; } - Q_UNREACHABLE(); - return QString(); + Q_UNREACHABLE_RETURN(QString()); } bool QWizardPrivate::ensureButton(QWizard::WizardButton which) const diff --git a/src/widgets/itemviews/qheaderview.cpp b/src/widgets/itemviews/qheaderview.cpp index 90c3b282ee..e231345437 100644 --- a/src/widgets/itemviews/qheaderview.cpp +++ b/src/widgets/itemviews/qheaderview.cpp @@ -3723,8 +3723,7 @@ static Qt::SortOrder flipOrder(Qt::SortOrder order) case Qt::DescendingOrder: return Qt::AscendingOrder; }; - Q_UNREACHABLE(); - return Qt::AscendingOrder; + Q_UNREACHABLE_RETURN(Qt::AscendingOrder); }; void QHeaderViewPrivate::flipSortIndicator(int section) diff --git a/tests/auto/corelib/global/qtendian/tst_qtendian.cpp b/tests/auto/corelib/global/qtendian/tst_qtendian.cpp index 401367ecaa..885e693c8d 100644 --- a/tests/auto/corelib/global/qtendian/tst_qtendian.cpp +++ b/tests/auto/corelib/global/qtendian/tst_qtendian.cpp @@ -430,8 +430,7 @@ void tst_QtEndian::endianBitfieldUnions() testBitfieldUnion(); return; } - Q_UNREACHABLE(); - return; + Q_UNREACHABLE_RETURN(); case QSysInfo::BigEndian: switch (signedness) { case Unsigned: @@ -441,8 +440,7 @@ void tst_QtEndian::endianBitfieldUnions() testBitfieldUnion(); return; } - Q_UNREACHABLE(); - return; + Q_UNREACHABLE_RETURN(); } } diff --git a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp index 1dbaf33e32..90b1b5c29a 100644 --- a/tests/auto/other/qobjectrace/tst_qobjectrace.cpp +++ b/tests/auto/other/qobjectrace/tst_qobjectrace.cpp @@ -309,8 +309,7 @@ public slots: break; } - Q_UNREACHABLE(); - return false; + Q_UNREACHABLE_RETURN(false); } private: diff --git a/tests/benchmarks/corelib/tools/qcryptographichash/tst_bench_qcryptographichash.cpp b/tests/benchmarks/corelib/tools/qcryptographichash/tst_bench_qcryptographichash.cpp index 719ba7a8c1..85bf863f9d 100644 --- a/tests/benchmarks/corelib/tools/qcryptographichash/tst_bench_qcryptographichash.cpp +++ b/tests/benchmarks/corelib/tools/qcryptographichash/tst_bench_qcryptographichash.cpp @@ -80,8 +80,7 @@ const char *algoname(int i) case QCryptographicHash::Blake2s_256: return "blake2s_256-"; } - Q_UNREACHABLE(); - return nullptr; + Q_UNREACHABLE_RETURN(nullptr); } tst_QCryptographicHash::tst_QCryptographicHash() -- cgit v1.2.3