aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Mutz <[email protected]>2022-10-13 23:18:06 +0200
committerMarc Mutz <[email protected]>2022-10-20 23:59:33 +0200
commit534241f723161ab79d9a85b2c8145d571f0d99f9 (patch)
tree1e130c190346202afe4dd2deb4292b180f0c9b48
parentdbff59d279182e6cd35be9a7f5240e666ba02eee (diff)
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. There was one false positive, suppressed it with NOLINTNEXTLINE. It's not really a false positiive, 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. Change-Id: I3855b2dc8523db1ea860f72ad9818738162495c6 Reviewed-by: Qt CI Bot <[email protected]> Reviewed-by: Fabian Kosmale <[email protected]>
-rw-r--r--src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp9
-rw-r--r--src/qml/common/qv4staticvalue_p.h3
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp9
-rw-r--r--src/qml/compiler/qv4codegen.cpp81
-rw-r--r--src/qml/jsapi/qjsmanagedvalue.cpp3
-rw-r--r--src/qml/jsapi/qjsprimitivevalue.h12
-rw-r--r--src/qml/jsapi/qjsvalue.cpp3
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp3
-rw-r--r--src/qml/jsruntime/qv4value.cpp9
-rw-r--r--src/qml/qml/qqml.cpp9
-rw-r--r--src/qml/qml/qqmltypedata.cpp4
-rw-r--r--src/qml/qml/qqmltypeloader.cpp6
-rw-r--r--src/qml/qml/qqmlvme_p.h3
-rw-r--r--src/qmlcompiler/qqmljsmetatypes.cpp4
-rw-r--r--src/qmlcompiler/qqmljsregistercontent.cpp3
-rw-r--r--src/qmlcompiler/qqmljsregistercontent_p.h3
-rw-r--r--src/qmlcompiler/qqmljstyperesolver.cpp12
-rw-r--r--src/qmldebug/qqmlprofilerevent.cpp3
-rw-r--r--src/qmldebug/qqmlprofilerevent_p.h3
-rw-r--r--src/qmlmodels/qqmllistaccessor.cpp6
-rw-r--r--src/qmlmodels/qqmlobjectmodel.cpp3
-rw-r--r--src/qmlmodels/qqmltableinstancemodel_p.h4
-rw-r--r--src/quick/items/qquickpalette.cpp2
-rw-r--r--src/quick/items/qquickpaletteproviderprivatebase_p.h3
-rw-r--r--src/quick/items/qquicktextutil_p.h3
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp6
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterialshader.cpp3
-rw-r--r--src/quickcontrols2/material/qquickmaterialstyle.cpp3
-rw-r--r--src/quickshapes/qquickshapegenericrenderer.cpp3
-rw-r--r--src/quicktemplates2/qquickpopup.cpp6
-rw-r--r--tests/auto/qml/qjsprimitivevalue/tst_qjsprimitivevalue.cpp6
-rw-r--r--tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp3
-rw-r--r--tests/auto/qml/qqmllanguage/testtypes.h3
-rw-r--r--tools/qmljsrootgen/main.cpp3
-rw-r--r--tools/qmlscene/main.cpp3
-rw-r--r--tools/qmltc/qmltcvisitor.cpp3
36 files changed, 84 insertions, 161 deletions
diff --git a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp
index 3afdaa53f1..fef0773613 100644
--- a/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp
+++ b/src/plugins/qmltooling/qmldbg_preview/qqmlpreviewfileengine.cpp
@@ -113,8 +113,7 @@ bool QQmlPreviewFileEngine::open(QIODevice::OpenMode flags,
case QQmlPreviewFileLoader::Fallback:
return m_fallback->open(flags, permissions);
default:
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
}
@@ -129,8 +128,7 @@ bool QQmlPreviewFileEngine::close()
case QQmlPreviewFileLoader::Directory:
return false;
default:
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
}
@@ -293,8 +291,7 @@ bool QQmlPreviewFileEngine::setSize(qint64 size)
case QQmlPreviewFileLoader::Directory:
return false;
default:
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
}
diff --git a/src/qml/common/qv4staticvalue_p.h b/src/qml/common/qv4staticvalue_p.h
index 1c2343013b..001666d08a 100644
--- a/src/qml/common/qv4staticvalue_p.h
+++ b/src/qml/common/qv4staticvalue_p.h
@@ -366,8 +366,7 @@ struct StaticValue
return 0; // Coercion of NaN to int, results in 0;
}
- Q_UNREACHABLE();
- return 0;
+ Q_UNREACHABLE_RETURN(0);
}
ReturnedValue *data_ptr() { return &_val; }
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index 8ed900e9e1..fbaf34abe1 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -483,8 +483,7 @@ QString IRBuilder::signalNameFromSignalPropertyName(const QString &signalPropert
}
}
- Q_UNREACHABLE();
- return QString();
+ Q_UNREACHABLE_RETURN(QString());
}
bool IRBuilder::visit(QQmlJS::AST::UiArrayMemberList *ast)
@@ -803,8 +802,7 @@ private:
return Pragma::FunctionSignatureBehavior;
}
- Q_UNREACHABLE();
- return Pragma::PragmaType(-1);
+ Q_UNREACHABLE_RETURN(Pragma::PragmaType(-1));
}
static bool assign(Pragma *pragma, QStringView value)
@@ -869,8 +867,7 @@ private:
default:
break;
}
- Q_UNREACHABLE();
- return QLatin1StringView();
+ Q_UNREACHABLE_RETURN(QLatin1StringView());
}
};
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 2f5a9bd55f..6f8e572702 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -759,86 +759,72 @@ void Codegen::destructurePattern(Pattern *p, const Reference &rhs)
bool Codegen::visit(ArgumentList *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(CaseBlock *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(CaseClause *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(CaseClauses *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(Catch *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(DefaultClause *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(Elision *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(Finally *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(FormalParameterList *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(Program *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(PatternElement *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(PatternElementList *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(PatternProperty *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(PatternPropertyList *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(ExportDeclaration *ast)
@@ -879,68 +865,57 @@ bool Codegen::visit(TypeAnnotation *ast)
bool Codegen::visit(StatementList *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(UiArrayMemberList *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(UiImport *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(UiHeaderItemList *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(UiPragma *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(UiObjectInitializer *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(UiObjectMemberList *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(UiParameterList *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(UiProgram *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(UiQualifiedId *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(VariableDeclarationList *)
{
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
bool Codegen::visit(ClassExpression *ast)
@@ -4473,8 +4448,7 @@ void Codegen::Reference::storeAccumulator() const
}
switch (type) {
case Super:
- Q_UNREACHABLE();
- return;
+ Q_UNREACHABLE_RETURN();
case SuperProperty:
Instruction::StoreSuperProperty store;
store.property = property.stackSlot();
@@ -4562,8 +4536,7 @@ void Codegen::Reference::loadInAccumulator() const
case Accumulator:
return;
case Super:
- Q_UNREACHABLE();
- return;
+ Q_UNREACHABLE_RETURN();
case SuperProperty:
tdzCheckStackSlot(property, subscriptRequiresTDZCheck);
Instruction::LoadSuperProperty load;
diff --git a/src/qml/jsapi/qjsmanagedvalue.cpp b/src/qml/jsapi/qjsmanagedvalue.cpp
index 8ae1ef3dd2..eeadf875de 100644
--- a/src/qml/jsapi/qjsmanagedvalue.cpp
+++ b/src/qml/jsapi/qjsmanagedvalue.cpp
@@ -634,8 +634,7 @@ QVariant QJSManagedValue::toVariant() const
if (d->as<QV4::Managed>())
return QV4::ExecutionEngine::toVariant(*d, QMetaType{}, true);
- Q_UNREACHABLE();
- return QVariant();
+ Q_UNREACHABLE_RETURN(QVariant());
}
/*!
diff --git a/src/qml/jsapi/qjsprimitivevalue.h b/src/qml/jsapi/qjsprimitivevalue.h
index bc32d554ae..9ac12dc86a 100644
--- a/src/qml/jsapi/qjsprimitivevalue.h
+++ b/src/qml/jsapi/qjsprimitivevalue.h
@@ -227,8 +227,7 @@ public:
case String: return asString();
}
- Q_UNREACHABLE();
- return QString();
+ Q_UNREACHABLE_RETURN(QString());
}
QVariant toVariant() const
@@ -242,8 +241,7 @@ public:
case String: return QVariant(asString());
}
- Q_UNREACHABLE();
- return QVariant();
+ Q_UNREACHABLE_RETURN(QVariant());
}
friend inline QJSPrimitiveValue operator+(const QJSPrimitiveValue &lhs,
@@ -629,8 +627,7 @@ private:
break;
}
- Q_UNREACHABLE();
- return QJSPrimitiveUndefined();
+ Q_UNREACHABLE_RETURN(QJSPrimitiveUndefined());
}
constexpr bool isNanOrUndefined() const
@@ -742,8 +739,7 @@ private:
else if constexpr (std::is_same_v<T, QString>)
return getString();
- Q_UNREACHABLE();
- return T();
+ Q_UNREACHABLE_RETURN(T());
}
private:
diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp
index 5c864f9928..3f51b902b9 100644
--- a/src/qml/jsapi/qjsvalue.cpp
+++ b/src/qml/jsapi/qjsvalue.cpp
@@ -371,8 +371,7 @@ QJSValue::ErrorType QJSValue::errorType() const
case QV4::Heap::ErrorObject::URIError:
return URIError;
}
- Q_UNREACHABLE();
- return NoError;
+ Q_UNREACHABLE_RETURN(NoError);
}
/*!
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index bb89dd87b2..e83c111251 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -316,8 +316,7 @@ static OptionalReturnedValue getPropertyFromImports(
v4, qobj, qmlContext->imports(), r.importNamespace,
Heap::QQmlTypeWrapper::ExcludeEnums));
}
- Q_UNREACHABLE();
- return OptionalReturnedValue();
+ Q_UNREACHABLE_RETURN(OptionalReturnedValue());
}
ReturnedValue QObjectWrapper::getQmlProperty(
diff --git a/src/qml/jsruntime/qv4value.cpp b/src/qml/jsruntime/qv4value.cpp
index 8962932a66..223a004602 100644
--- a/src/qml/jsruntime/qv4value.cpp
+++ b/src/qml/jsruntime/qv4value.cpp
@@ -91,8 +91,7 @@ static QString primitiveToQString(const Value *value)
switch (value->type()) {
case Value::Empty_Type:
Q_ASSERT(!"empty Value encountered");
- Q_UNREACHABLE();
- return QString();
+ Q_UNREACHABLE_RETURN(QString());
case Value::Undefined_Type:
return QStringLiteral("undefined");
case Value::Null_Type:
@@ -103,8 +102,7 @@ static QString primitiveToQString(const Value *value)
else
return QStringLiteral("false");
case Value::Managed_Type:
- Q_UNREACHABLE();
- return QString();
+ Q_UNREACHABLE_RETURN(QString());
case Value::Integer_Type: {
QString str;
RuntimeHelpers::numberToString(&str, (double)value->int_32(), 10);
@@ -117,8 +115,7 @@ static QString primitiveToQString(const Value *value)
}
} // switch
- Q_UNREACHABLE();
- return QString();
+ Q_UNREACHABLE_RETURN(QString());
}
diff --git a/src/qml/qml/qqml.cpp b/src/qml/qml/qqml.cpp
index 68cf1dc130..d5e98f1805 100644
--- a/src/qml/qml/qqml.cpp
+++ b/src/qml/qml/qqml.cpp
@@ -1411,8 +1411,7 @@ bool AOTCompiledContext::loadScopeObjectPropertyLookup(uint index, void *target)
return true;
}
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
void AOTCompiledContext::initLoadScopeObjectPropertyLookup(uint index, QMetaType type) const
@@ -1595,8 +1594,7 @@ bool AOTCompiledContext::getObjectLookup(uint index, QObject *object, void *targ
return true;
}
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
void AOTCompiledContext::initGetObjectLookup(uint index, QObject *object, QMetaType type) const
@@ -1701,8 +1699,7 @@ bool AOTCompiledContext::setObjectLookup(uint index, QObject *object, void *valu
return true;
}
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
void AOTCompiledContext::initSetObjectLookup(uint index, QObject *object, QMetaType type) const
diff --git a/src/qml/qml/qqmltypedata.cpp b/src/qml/qml/qqmltypedata.cpp
index 43354dac6d..dd70af34bf 100644
--- a/src/qml/qml/qqmltypedata.cpp
+++ b/src/qml/qml/qqmltypedata.cpp
@@ -75,8 +75,8 @@ QV4::ExecutableCompilationUnit *QQmlTypeData::compilationUnitForInlineComponent(
return m_inlineComponentToCompiledData[icIt->nameIndex].data();
}
}
- Q_UNREACHABLE();
- return nullptr; // make integrity happy
+ Q_UNREACHABLE_RETURN(nullptr);
+ // make integrity happy
}
void QQmlTypeData::registerCallback(TypeDataCallback *callback)
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index 7b763030f3..9a575d4986 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -725,12 +725,10 @@ bool QQmlTypeLoader::Blob::addImport(
case QV4::CompiledData::Import::ImportScript:
return addScriptImport(import);
case QV4::CompiledData::Import::ImportInlineComponent:
- Q_UNREACHABLE(); // addImport is never called with an inline component import
- return false;
+ Q_UNREACHABLE_RETURN(false); // addImport is never called with an inline component import
}
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
void QQmlTypeLoader::Blob::dependencyComplete(QQmlDataBlob *blob)
diff --git a/src/qml/qml/qqmlvme_p.h b/src/qml/qml/qqmlvme_p.h
index d5b2329395..ac0694354d 100644
--- a/src/qml/qml/qqmlvme_p.h
+++ b/src/qml/qml/qqmlvme_p.h
@@ -115,8 +115,7 @@ bool QQmlInstantiationInterrupt::shouldInterrupt() const
case Flag:
return !runWhile->load(std::memory_order_acquire) || (nsecs && timer.nsecsElapsed() > nsecs);
}
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
QT_END_NAMESPACE
diff --git a/src/qmlcompiler/qqmljsmetatypes.cpp b/src/qmlcompiler/qqmljsmetatypes.cpp
index 235662ca64..9a205bec01 100644
--- a/src/qmlcompiler/qqmljsmetatypes.cpp
+++ b/src/qmlcompiler/qqmljsmetatypes.cpp
@@ -112,8 +112,8 @@ QSharedPointer<const QQmlJSScope> QQmlJSMetaPropertyBinding::literalType(const Q
default:
return {};
}
- Q_UNREACHABLE();
- return {}; // needed on some compilers which do not see that every case in the switch returns
+ Q_UNREACHABLE_RETURN({});
+ // needed on some compilers which do not see that every case in the switch returns
}
QT_END_NAMESPACE
diff --git a/src/qmlcompiler/qqmljsregistercontent.cpp b/src/qmlcompiler/qqmljsregistercontent.cpp
index aec772ca5b..60f51bc302 100644
--- a/src/qmlcompiler/qqmljsregistercontent.cpp
+++ b/src/qmlcompiler/qqmljsregistercontent.cpp
@@ -54,8 +54,7 @@ QString QQmlJSRegisterContent::descriptiveName() const
std::get<ConvertedTypes>(m_content).result->internalName());
}
}
- Q_UNREACHABLE();
- return result + u"wat?"_s;
+ Q_UNREACHABLE_RETURN(result + u"wat?"_s);
}
bool QQmlJSRegisterContent::isList() const
diff --git a/src/qmlcompiler/qqmljsregistercontent_p.h b/src/qmlcompiler/qqmljsregistercontent_p.h
index 4e8c2f44b6..1ca44fd0c3 100644
--- a/src/qmlcompiler/qqmljsregistercontent_p.h
+++ b/src/qmlcompiler/qqmljsregistercontent_p.h
@@ -134,8 +134,7 @@ public:
return qHash(std::get<ConvertedTypes>(registerContent.m_content), seed);
}
- Q_UNREACHABLE();
- return seed;
+ Q_UNREACHABLE_RETURN(seed);
}
static QQmlJSRegisterContent create(const QQmlJSScope::ConstPtr &storedType,
diff --git a/src/qmlcompiler/qqmljstyperesolver.cpp b/src/qmlcompiler/qqmljstyperesolver.cpp
index 5eb9980ca1..db06d926fc 100644
--- a/src/qmlcompiler/qqmljstyperesolver.cpp
+++ b/src/qmlcompiler/qqmljstyperesolver.cpp
@@ -330,8 +330,7 @@ QQmlJSTypeResolver::containedType(const QQmlJSRegisterContent &container) const
if (container.isConversion())
return container.conversionResult();
- Q_UNREACHABLE();
- return {};
+ Q_UNREACHABLE_RETURN({});
}
void QQmlJSTypeResolver::trackListPropertyType(
@@ -411,8 +410,7 @@ QQmlJSRegisterContent QQmlJSTypeResolver::transformed(
origin.variant(), (this->*op)(origin.scopeType()));
}
- Q_UNREACHABLE();
- return {};
+ Q_UNREACHABLE_RETURN({});
}
QQmlJSRegisterContent QQmlJSTypeResolver::referenceTypeForName(
@@ -804,8 +802,7 @@ static QQmlJSRegisterContent::ContentVariant scopeContentVariant(QQmlJSScope::Ex
case QQmlJSScope::ExtensionNamespace:
break;
}
- Q_UNREACHABLE();
- return QQmlJSRegisterContent::Unknown;
+ Q_UNREACHABLE_RETURN(QQmlJSRegisterContent::Unknown);
}
static bool isRevisionAllowed(int memberRevision, const QQmlJSScope::ConstPtr &scope)
@@ -1201,8 +1198,7 @@ QQmlJSRegisterContent QQmlJSTypeResolver::memberType(const QQmlJSRegisterContent
return result.isValid() ? result : memberEnumType(type.scopeType(), name);
}
- Q_UNREACHABLE();
- return {};
+ Q_UNREACHABLE_RETURN({});
}
QQmlJSRegisterContent QQmlJSTypeResolver::valueType(const QQmlJSRegisterContent &list) const
diff --git a/src/qmldebug/qqmlprofilerevent.cpp b/src/qmldebug/qqmlprofilerevent.cpp
index 0cea64b41f..59e9eb4ebd 100644
--- a/src/qmldebug/qqmlprofilerevent.cpp
+++ b/src/qmldebug/qqmlprofilerevent.cpp
@@ -67,8 +67,7 @@ static inline Number readNumber(QDataStream &stream, qint8 type)
return static_cast<Number>(value);
}
default:
- Q_UNREACHABLE();
- return 0;
+ Q_UNREACHABLE_RETURN(0);
}
}
diff --git a/src/qmldebug/qqmlprofilerevent_p.h b/src/qmldebug/qqmlprofilerevent_p.h
index 88aec820cf..9870e47897 100644
--- a/src/qmldebug/qqmlprofilerevent_p.h
+++ b/src/qmldebug/qqmlprofilerevent_p.h
@@ -175,8 +175,7 @@ QT_WARNING_POP
case Inline8Bit:
return QString::fromUtf8(m_data.internalChar, m_dataLength);
default:
- Q_UNREACHABLE();
- return QString();
+ Q_UNREACHABLE_RETURN(QString());
}
}
diff --git a/src/qmlmodels/qqmllistaccessor.cpp b/src/qmlmodels/qqmllistaccessor.cpp
index 0e57c3c4e9..f1728d5e6c 100644
--- a/src/qmlmodels/qqmllistaccessor.cpp
+++ b/src/qmlmodels/qqmllistaccessor.cpp
@@ -117,8 +117,7 @@ qsizetype QQmlListAccessor::count() const
case Invalid:
return 0;
}
- Q_UNREACHABLE();
- return 0;
+ Q_UNREACHABLE_RETURN(0);
}
QVariant QQmlListAccessor::at(qsizetype idx) const
@@ -159,8 +158,7 @@ QVariant QQmlListAccessor::at(qsizetype idx) const
case Invalid:
return QVariant();
}
- Q_UNREACHABLE();
- return QVariant();
+ Q_UNREACHABLE_RETURN(QVariant());
}
bool QQmlListAccessor::isValid() const
diff --git a/src/qmlmodels/qqmlobjectmodel.cpp b/src/qmlmodels/qqmlobjectmodel.cpp
index 970a1e541f..4921010911 100644
--- a/src/qmlmodels/qqmlobjectmodel.cpp
+++ b/src/qmlmodels/qqmlobjectmodel.cpp
@@ -422,8 +422,7 @@ bool QQmlInstanceModel::setRequiredProperty(int index, const QString &name, cons
Q_UNUSED(value);
// The view should not call this function, unless
// it's actually handled in a subclass.
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
QT_END_NAMESPACE
diff --git a/src/qmlmodels/qqmltableinstancemodel_p.h b/src/qmlmodels/qqmltableinstancemodel_p.h
index 8fa2b30c14..6d3f455adc 100644
--- a/src/qmlmodels/qqmltableinstancemodel_p.h
+++ b/src/qmlmodels/qqmltableinstancemodel_p.h
@@ -85,9 +85,9 @@ public:
bool setRequiredProperty(int index, const QString &name, const QVariant &value) final;
- QVariant variantValue(int, const QString &) override { Q_UNREACHABLE(); return QVariant(); }
+ QVariant variantValue(int, const QString &) override { Q_UNREACHABLE_RETURN(QVariant()); }
void setWatchedRoles(const QList<QByteArray> &) override { Q_UNREACHABLE(); }
- int indexOf(QObject *, QObject *) const override { Q_UNREACHABLE(); return 0; }
+ int indexOf(QObject *, QObject *) const override { Q_UNREACHABLE_RETURN(0); }
private:
enum DestructionMode {
diff --git a/src/quick/items/qquickpalette.cpp b/src/quick/items/qquickpalette.cpp
index 9a72807fe1..07d1e61b59 100644
--- a/src/quick/items/qquickpalette.cpp
+++ b/src/quick/items/qquickpalette.cpp
@@ -23,9 +23,9 @@ static constexpr bool is_valid(QPalette::ColorGroup cg) noexcept
// GCC 8.x does not tread __builtin_unreachable() as constexpr
#if defined(Q_CC_INTEL) || defined(Q_CC_CLANG) || (defined(Q_CC_GNU) && Q_CC_GNU >= 900)
+ // NOLINTNEXTLINE(qt-use-unreachable-return): Triggers on Clang, breaking GCC 8
Q_UNREACHABLE();
#endif
-
return false;
}
diff --git a/src/quick/items/qquickpaletteproviderprivatebase_p.h b/src/quick/items/qquickpaletteproviderprivatebase_p.h
index 0b701f777b..a0e0302ea9 100644
--- a/src/quick/items/qquickpaletteproviderprivatebase_p.h
+++ b/src/quick/items/qquickpaletteproviderprivatebase_p.h
@@ -323,8 +323,7 @@ void QQuickPaletteProviderPrivateBase<I, Impl>::updateChildrenPalettes(const QPa
* nothing in this instantiation of updateChildrenPalettes and instead add an override in
* QQuickWindowPrivate, which does the correct thing.
*/
- Q_UNREACHABLE(); // You are not supposed to call this function
- return;
+ Q_UNREACHABLE_RETURN(); // You are not supposed to call this function
} else {
if (auto root = rootItem(*itemWithPalette())) {
for (auto &&child : root->childItems()) {
diff --git a/src/quick/items/qquicktextutil_p.h b/src/quick/items/qquicktextutil_p.h
index 58da5e4947..212c488c73 100644
--- a/src/quick/items/qquicktextutil_p.h
+++ b/src/quick/items/qquicktextutil_p.h
@@ -101,8 +101,7 @@ typename T::RenderType QQuickTextUtil::textRenderType()
return T::NativeRendering;
}
- Q_UNREACHABLE();
- return T::QtRendering;
+ Q_UNREACHABLE_RETURN(T::QtRendering);
}
QT_END_NAMESPACE
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index bab9bff07e..874d2f08e7 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -115,8 +115,7 @@ QRhiVertexInputAttribute::Format qsg_vertexInputFormat(const QSGGeometry::Attrib
break;
}
qWarning("Unsupported attribute type 0x%x with %d components", a.type, a.tupleSize);
- Q_UNREACHABLE();
- return QRhiVertexInputAttribute::Float;
+ Q_UNREACHABLE_RETURN(QRhiVertexInputAttribute::Float);
}
static QRhiVertexInputLayout calculateVertexInputLayout(const QSGMaterialShader *s, const QSGGeometry *geometry, bool batchable)
@@ -169,8 +168,7 @@ QRhiCommandBuffer::IndexFormat qsg_indexFormat(const QSGGeometry *geometry)
return QRhiCommandBuffer::IndexUInt32;
break;
default:
- Q_UNREACHABLE();
- return QRhiCommandBuffer::IndexUInt16;
+ Q_UNREACHABLE_RETURN(QRhiCommandBuffer::IndexUInt16);
}
}
diff --git a/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp b/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp
index 268f34d77b..b4090eb9cd 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp
+++ b/src/quick/scenegraph/coreapi/qsgmaterialshader.cpp
@@ -336,8 +336,7 @@ static inline QShader::Stage toShaderStage(QSGMaterialShader::Stage stage)
case QSGMaterialShader::FragmentStage:
return QShader::FragmentStage;
default:
- Q_UNREACHABLE();
- return QShader::VertexStage;
+ Q_UNREACHABLE_RETURN(QShader::VertexStage);
}
}
diff --git a/src/quickcontrols2/material/qquickmaterialstyle.cpp b/src/quickcontrols2/material/qquickmaterialstyle.cpp
index 9114462828..dbe7347acc 100644
--- a/src/quickcontrols2/material/qquickmaterialstyle.cpp
+++ b/src/quickcontrols2/material/qquickmaterialstyle.cpp
@@ -1156,8 +1156,7 @@ QColor QQuickMaterialStyle::shade(const QColor &color, Shade shade) const
case ShadeA700:
return darkerShade(color, m_theme == Light ? 0.12 : 0.38);
default:
- Q_UNREACHABLE();
- return QColor();
+ Q_UNREACHABLE_RETURN(QColor());
}
}
diff --git a/src/quickshapes/qquickshapegenericrenderer.cpp b/src/quickshapes/qquickshapegenericrenderer.cpp
index b91f2d59a1..680bd6c60f 100644
--- a/src/quickshapes/qquickshapegenericrenderer.cpp
+++ b/src/quickshapes/qquickshapegenericrenderer.cpp
@@ -564,8 +564,7 @@ void QQuickShapeGenericRenderer::updateFillNode(ShapePathData *d, QQuickShapeGen
gradMat = QQuickShapeGenericStrokeFillNode::MatConicalGradient;
break;
default:
- Q_UNREACHABLE();
- return;
+ Q_UNREACHABLE_RETURN();
}
n->activateMaterial(m_item->window(), gradMat);
if (d->effectiveDirty & DirtyFillGradient) {
diff --git a/src/quicktemplates2/qquickpopup.cpp b/src/quicktemplates2/qquickpopup.cpp
index 596eb7103e..f13d5e8de8 100644
--- a/src/quicktemplates2/qquickpopup.cpp
+++ b/src/quicktemplates2/qquickpopup.cpp
@@ -393,8 +393,7 @@ bool QQuickPopupPrivate::handleMouseEvent(QQuickItem *item, QMouseEvent *event)
case QEvent::MouseButtonRelease:
return handleRelease(item, event->scenePosition(), event->timestamp());
default:
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
}
@@ -406,8 +405,7 @@ bool QQuickPopupPrivate::handleHoverEvent(QQuickItem *item, QHoverEvent *event)
case QEvent::HoverLeave:
return blockInput(item, event->scenePosition());
default:
- Q_UNREACHABLE();
- return false;
+ Q_UNREACHABLE_RETURN(false);
}
}
diff --git a/tests/auto/qml/qjsprimitivevalue/tst_qjsprimitivevalue.cpp b/tests/auto/qml/qjsprimitivevalue/tst_qjsprimitivevalue.cpp
index ea17eeae89..0c46fc9f6b 100644
--- a/tests/auto/qml/qjsprimitivevalue/tst_qjsprimitivevalue.cpp
+++ b/tests/auto/qml/qjsprimitivevalue/tst_qjsprimitivevalue.cpp
@@ -97,8 +97,7 @@ QString toString(BinaryOperator op) {
case Mod: return "%";
}
- Q_UNREACHABLE();
- return QString();
+ Q_UNREACHABLE_RETURN(QString());
}
template<typename Result>
@@ -239,8 +238,7 @@ QString toString(UnaryOperator op) {
return "--";
}
- Q_UNREACHABLE();
- return QString();
+ Q_UNREACHABLE_RETURN(QString());
}
template<typename Result, UnaryOperator Operator>
diff --git a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
index 3d942648fd..1a0d211989 100644
--- a/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
+++ b/tests/auto/qml/qmlcppcodegen/tst_qmlcppcodegen.cpp
@@ -2624,8 +2624,7 @@ double jsEval(double arg1, double arg2, const QString &op, QJSEngine *engine)
return evalBinaryConst(u"<<"_s);
qDebug() << op;
- Q_UNREACHABLE();
- return 0;
+ Q_UNREACHABLE_RETURN(0);
}
void tst_QmlCppCodegen::mathOperations()
diff --git a/tests/auto/qml/qqmllanguage/testtypes.h b/tests/auto/qml/qqmllanguage/testtypes.h
index 060c867a27..9ba5132bb4 100644
--- a/tests/auto/qml/qqmllanguage/testtypes.h
+++ b/tests/auto/qml/qqmllanguage/testtypes.h
@@ -1818,8 +1818,7 @@ public:
int c()
{
- Q_UNREACHABLE();
- return 1111;
+ Q_UNREACHABLE_RETURN(1111);
}
};
diff --git a/tools/qmljsrootgen/main.cpp b/tools/qmljsrootgen/main.cpp
index 77abd1be54..2bd54692d1 100644
--- a/tools/qmljsrootgen/main.cpp
+++ b/tools/qmljsrootgen/main.cpp
@@ -86,8 +86,7 @@ static QString findClassName(const QJSManagedValue &value)
if (QV4::ScopedValue scoped(scope, asManaged(value)); scoped->isManaged())
return scoped->managed()->vtable()->className;
- Q_UNREACHABLE();
- return QString();
+ Q_UNREACHABLE_RETURN(QString());
}
static QString buildClass(const QJSManagedValue &value, QJsonArray *classes,
diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp
index 891b7534bd..123844ebb3 100644
--- a/tools/qmlscene/main.cpp
+++ b/tools/qmlscene/main.cpp
@@ -397,8 +397,7 @@ static QQuickWindow::TextRenderType parseTextRenderType(const QString &renderTyp
usage();
- Q_UNREACHABLE();
- return QQuickWindow::QtTextRendering;
+ Q_UNREACHABLE_RETURN(QQuickWindow::QtTextRendering);
}
int main(int argc, char ** argv)
diff --git a/tools/qmltc/qmltcvisitor.cpp b/tools/qmltc/qmltcvisitor.cpp
index c36290a360..504ccbf159 100644
--- a/tools/qmltc/qmltcvisitor.cpp
+++ b/tools/qmltc/qmltcvisitor.cpp
@@ -352,8 +352,7 @@ QQmlJSScope::ConstPtr fetchType(const QQmlJSMetaPropertyBinding &binding)
}
// coverity complains about the unreachable return below,
// some compilers; some compilers complain without it
- Q_UNREACHABLE();
- return {};
+ Q_UNREACHABLE_RETURN({});
}
template<typename Predicate>