moc: improve control of Q_UNUSED / (void) in qt_static_metacall()
Because I'm pedantic. Change-Id: I3ac643db1a74864f0d69fffdebe7df6c6f1b1c28 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> (cherry picked from commit e001ae19c700ac694a0ff1fea365e07e6e64f907) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
855bfed477
commit
973aeb422a
@ -1019,7 +1019,13 @@ void Generator::generateStaticMetacall()
|
||||
fprintf(out, "void %s::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)\n{\n",
|
||||
cdef->qualified.constData());
|
||||
|
||||
bool isUsed_a = false;
|
||||
enum UsedArgs {
|
||||
UsedO = 1,
|
||||
UsedC = 2,
|
||||
UsedId = 4,
|
||||
UsedA = 8,
|
||||
};
|
||||
uint usedArgs = 0;
|
||||
|
||||
const auto generateCtorArguments = [&](int ctorindex) {
|
||||
const FunctionDef &f = cdef->constructorList.at(ctorindex);
|
||||
@ -1063,7 +1069,7 @@ void Generator::generateStaticMetacall()
|
||||
fprintf(out, " default: break;\n");
|
||||
fprintf(out, " }\n");
|
||||
fprintf(out, " }\n");
|
||||
isUsed_a = true;
|
||||
usedArgs |= UsedC | UsedId | UsedA;
|
||||
}
|
||||
|
||||
QList<FunctionDef> methodList;
|
||||
@ -1072,6 +1078,7 @@ void Generator::generateStaticMetacall()
|
||||
methodList += cdef->methodList;
|
||||
|
||||
if (!methodList.isEmpty()) {
|
||||
usedArgs |= UsedO | UsedC | UsedId;
|
||||
fprintf(out, " if (_c == QMetaObject::InvokeMetaMethod) {\n");
|
||||
if (cdef->hasQObject) {
|
||||
#ifndef QT_NO_DEBUG
|
||||
@ -1097,6 +1104,7 @@ void Generator::generateStaticMetacall()
|
||||
|
||||
if (f.isRawSlot) {
|
||||
fprintf(out, "QMethodRawArguments{ _a }");
|
||||
usedArgs |= UsedA;
|
||||
} else {
|
||||
const auto begin = f.arguments.cbegin();
|
||||
const auto end = f.arguments.cend();
|
||||
@ -1105,7 +1113,7 @@ void Generator::generateStaticMetacall()
|
||||
if (it != begin)
|
||||
fprintf(out, ",");
|
||||
fprintf(out, "(*reinterpret_cast< %s>(_a[%d]))",a.typeNameForCast.constData(), offset++);
|
||||
isUsed_a = true;
|
||||
usedArgs |= UsedA;
|
||||
}
|
||||
if (f.isPrivateSignal) {
|
||||
if (!f.arguments.isEmpty())
|
||||
@ -1117,7 +1125,7 @@ void Generator::generateStaticMetacall()
|
||||
if (f.normalizedType != "void") {
|
||||
fprintf(out, "\n if (_a[0]) *reinterpret_cast< %s*>(_a[0]) = std::move(_r); } ",
|
||||
noRef(f.normalizedType).constData());
|
||||
isUsed_a = true;
|
||||
usedArgs |= UsedA;
|
||||
}
|
||||
fprintf(out, " break;\n");
|
||||
}
|
||||
@ -1151,11 +1159,12 @@ void Generator::generateStaticMetacall()
|
||||
}
|
||||
fprintf(out, " }\n");
|
||||
fprintf(out, " }\n");
|
||||
isUsed_a = true;
|
||||
usedArgs |= UsedC | UsedId | UsedA;
|
||||
}
|
||||
|
||||
}
|
||||
if (!cdef->signalList.isEmpty()) {
|
||||
usedArgs |= UsedC | UsedA;
|
||||
fprintf(out, " if (_c == QMetaObject::IndexOfMethod) {\n");
|
||||
fprintf(out, " int *result = reinterpret_cast<int *>(_a[0]);\n");
|
||||
bool anythingUsed = false;
|
||||
@ -1212,7 +1221,7 @@ void Generator::generateStaticMetacall()
|
||||
}
|
||||
fprintf(out, " }\n");
|
||||
fprintf(out, " }\n");
|
||||
isUsed_a = true;
|
||||
usedArgs |= UsedC | UsedId | UsedA;
|
||||
}
|
||||
|
||||
if (!cdef->propertyList.empty()) {
|
||||
@ -1231,6 +1240,10 @@ void Generator::generateStaticMetacall()
|
||||
needReset |= !p.reset.isEmpty();
|
||||
hasBindableProperties |= !p.bind.isEmpty();
|
||||
}
|
||||
if (needGet || needSet || hasBindableProperties || needReset)
|
||||
usedArgs |= UsedO | UsedC | UsedId;
|
||||
if (needGet || needSet || hasBindableProperties)
|
||||
usedArgs |= UsedA; // resetting doesn't need arguments
|
||||
|
||||
auto setupMemberAccess = [this]() {
|
||||
if (cdef->hasQObject) {
|
||||
@ -1377,15 +1390,14 @@ void Generator::generateStaticMetacall()
|
||||
}
|
||||
}
|
||||
|
||||
if (methodList.isEmpty()) {
|
||||
fprintf(out, " (void)_o;\n");
|
||||
if (cdef->constructorList.isEmpty() && automaticPropertyMetaTypes.isEmpty() && methodsWithAutomaticTypesHelper(methodList).isEmpty()) {
|
||||
fprintf(out, " (void)_id;\n");
|
||||
fprintf(out, " (void)_c;\n");
|
||||
}
|
||||
}
|
||||
if (!isUsed_a)
|
||||
fprintf(out, " (void)_a;\n");
|
||||
auto printUnused = [&](UsedArgs entry, const char *name) {
|
||||
if ((usedArgs & entry) == 0)
|
||||
fprintf(out, " (void)%s;\n", name);
|
||||
};
|
||||
printUnused(UsedO, "_o");
|
||||
printUnused(UsedC, "_c");
|
||||
printUnused(UsedId, "_id");
|
||||
printUnused(UsedA, "_a");
|
||||
|
||||
fprintf(out, "}\n");
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user