benchmarks: fix some (future) -Wunused-result warnings

Clang 10 warns about unused results of relational operators, which is
where this is coming from.

Fix by adding the usual prefix

  [[maybe_unused]] auto r = ~~~;

to silence the warning. Do this elsewhere, too, since [[nodiscard]] is
slowly being rolled out across all our APIs. This is not a complete
sweep, though.

Not picking to 5.15, because this pattern doesn't work there and I
don't want to introduce a new one.

Pick-to: 6.3 6.2
Change-Id: I40dd8ad07496b686979dce533e044cbb486e30f3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Marc Mutz 2022-01-22 21:13:28 +01:00
parent c00e443dcc
commit 6f1821dfa3
3 changed files with 28 additions and 28 deletions

View File

@ -188,7 +188,7 @@ void tst_QUrl::equality()
QUrl url("pics/avatar.png"); QUrl url("pics/avatar.png");
QUrl url2("pics/avatar2.png"); QUrl url2("pics/avatar2.png");
QBENCHMARK { QBENCHMARK {
url == url2; [[maybe_unused]] auto r = url == url2;
} }
} }
} }

View File

@ -55,7 +55,7 @@ private slots:
void tst_QUuid::createUuid() void tst_QUuid::createUuid()
{ {
QBENCHMARK { QBENCHMARK {
QUuid::createUuid(); [[maybe_unused]] auto r = QUuid::createUuid();
} }
} }
@ -70,7 +70,7 @@ void tst_QUuid::toString()
{ {
QUuid uuid = QUuid::createUuid(); QUuid uuid = QUuid::createUuid();
QBENCHMARK { QBENCHMARK {
uuid.toString(); [[maybe_unused]] auto r = uuid.toString();
} }
} }
@ -86,7 +86,7 @@ void tst_QUuid::toByteArray()
{ {
QUuid uuid = QUuid::createUuid(); QUuid uuid = QUuid::createUuid();
QBENCHMARK { QBENCHMARK {
uuid.toByteArray(); [[maybe_unused]] auto r = uuid.toByteArray();
} }
} }
@ -102,7 +102,7 @@ void tst_QUuid::toRfc4122()
{ {
QUuid uuid = QUuid::createUuid(); QUuid uuid = QUuid::createUuid();
QBENCHMARK { QBENCHMARK {
uuid.toRfc4122(); [[maybe_unused]] auto r = uuid.toRfc4122();
} }
} }
@ -168,7 +168,7 @@ void tst_QUuid::isNull()
{ {
QUuid uuid = QUuid(); QUuid uuid = QUuid();
QBENCHMARK { QBENCHMARK {
uuid.isNull(); [[maybe_unused]] auto r = uuid.isNull();
} }
} }
@ -178,7 +178,7 @@ void tst_QUuid::operatorLess()
uuid1 = QUuid::createUuid(); uuid1 = QUuid::createUuid();
uuid2 = QUuid::createUuid(); uuid2 = QUuid::createUuid();
QBENCHMARK { QBENCHMARK {
uuid1 < uuid2; [[maybe_unused]] auto r = uuid1 < uuid2;
} }
} }
@ -188,7 +188,7 @@ void tst_QUuid::operatorMore()
uuid1 = QUuid::createUuid(); uuid1 = QUuid::createUuid();
uuid2 = QUuid::createUuid(); uuid2 = QUuid::createUuid();
QBENCHMARK { QBENCHMARK {
uuid1 > uuid2; [[maybe_unused]] auto r = uuid1 > uuid2;
} }
} }

View File

@ -266,7 +266,7 @@ void tst_QTransform::operatorEqual()
QFETCH(QTransform, x2); QFETCH(QTransform, x2);
QTransform x = x1; QTransform x = x1;
QBENCHMARK { QBENCHMARK {
x == x2; [[maybe_unused]] auto r = x == x2;
} }
} }
@ -278,7 +278,7 @@ void tst_QTransform::operatorNotEqual()
QFETCH(QTransform, x2); QFETCH(QTransform, x2);
QTransform x = x1; QTransform x = x1;
QBENCHMARK { QBENCHMARK {
x != x2; [[maybe_unused]] auto r = x != x2;
} }
} }
@ -290,7 +290,7 @@ void tst_QTransform::operatorMultiply()
QFETCH(QTransform, x2); QFETCH(QTransform, x2);
QTransform x = x1; QTransform x = x1;
QBENCHMARK { QBENCHMARK {
x * x2; [[maybe_unused]] auto r = x * x2;
} }
} }
@ -357,7 +357,7 @@ void tst_QTransform::mapQPoint()
QFETCH(QTransform, transform); QFETCH(QTransform, transform);
QTransform x = transform; QTransform x = transform;
QBENCHMARK { QBENCHMARK {
x.map(QPoint(3, 3)); [[maybe_unused]] auto r = x.map(QPoint(3, 3));
} }
} }
@ -368,7 +368,7 @@ void tst_QTransform::mapQPointF()
QFETCH(QTransform, transform); QFETCH(QTransform, transform);
QTransform x = transform; QTransform x = transform;
QBENCHMARK { QBENCHMARK {
x.map(QPointF(3, 3)); [[maybe_unused]] auto r = x.map(QPointF(3, 3));
} }
} }
@ -379,7 +379,7 @@ void tst_QTransform::mapRect()
QFETCH(QTransform, transform); QFETCH(QTransform, transform);
QTransform x = transform; QTransform x = transform;
QBENCHMARK { QBENCHMARK {
x.mapRect(QRect(0, 0, 100, 100)); [[maybe_unused]] auto r = x.mapRect(QRect(0, 0, 100, 100));
} }
} }
@ -390,7 +390,7 @@ void tst_QTransform::mapRectF()
QFETCH(QTransform, transform); QFETCH(QTransform, transform);
QTransform x = transform; QTransform x = transform;
QBENCHMARK { QBENCHMARK {
x.mapRect(QRectF(0, 0, 100, 100)); [[maybe_unused]] auto r = x.mapRect(QRectF(0, 0, 100, 100));
} }
} }
@ -402,7 +402,7 @@ void tst_QTransform::mapQPolygon()
QTransform x = transform; QTransform x = transform;
QPolygon poly = QPolygon(QRect(0, 0, 100, 100)); QPolygon poly = QPolygon(QRect(0, 0, 100, 100));
QBENCHMARK { QBENCHMARK {
x.map(poly); [[maybe_unused]] auto r = x.map(poly);
} }
} }
@ -414,7 +414,7 @@ void tst_QTransform::mapQPolygonF()
QTransform x = transform; QTransform x = transform;
QPolygonF poly = QPolygonF(QRectF(0, 0, 100, 100)); QPolygonF poly = QPolygonF(QRectF(0, 0, 100, 100));
QBENCHMARK { QBENCHMARK {
x.map(poly); [[maybe_unused]] auto r = x.map(poly);
} }
} }
@ -428,7 +428,7 @@ void tst_QTransform::mapQRegion()
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
region += QRect(i * 10, i * 10, 100, 100); region += QRect(i * 10, i * 10, 100, 100);
QBENCHMARK { QBENCHMARK {
x.map(region); [[maybe_unused]] auto r = x.map(region);
} }
} }
@ -439,7 +439,7 @@ void tst_QTransform::mapToPolygon()
QFETCH(QTransform, transform); QFETCH(QTransform, transform);
QTransform x = transform; QTransform x = transform;
QBENCHMARK { QBENCHMARK {
x.mapToPolygon(QRect(0, 0, 100, 100)); [[maybe_unused]] auto r = x.mapToPolygon(QRect(0, 0, 100, 100));
} }
} }
@ -454,7 +454,7 @@ void tst_QTransform::mapQPainterPath()
for (int i = 0; i < 10; ++i) for (int i = 0; i < 10; ++i)
path.addEllipse(i * 10, i * 10, 100, 100); path.addEllipse(i * 10, i * 10, 100, 100);
QBENCHMARK { QBENCHMARK {
x.map(path); [[maybe_unused]] auto r = x.map(path);
} }
} }
@ -464,7 +464,7 @@ void tst_QTransform::isIdentity()
{ {
QFETCH(QTransform, transform); QFETCH(QTransform, transform);
QBENCHMARK { QBENCHMARK {
transform.isIdentity(); [[maybe_unused]] auto r = transform.isIdentity();
} }
} }
@ -474,7 +474,7 @@ void tst_QTransform::isAffine()
{ {
QFETCH(QTransform, transform); QFETCH(QTransform, transform);
QBENCHMARK { QBENCHMARK {
transform.isAffine(); [[maybe_unused]] auto r = transform.isAffine();
} }
} }
@ -484,7 +484,7 @@ void tst_QTransform::isInvertible()
{ {
QFETCH(QTransform, transform); QFETCH(QTransform, transform);
QBENCHMARK { QBENCHMARK {
transform.isInvertible(); [[maybe_unused]] auto r = transform.isInvertible();
} }
} }
@ -494,7 +494,7 @@ void tst_QTransform::isRotating()
{ {
QFETCH(QTransform, transform); QFETCH(QTransform, transform);
QBENCHMARK { QBENCHMARK {
transform.isRotating(); [[maybe_unused]] auto r = transform.isRotating();
} }
} }
@ -504,7 +504,7 @@ void tst_QTransform::isScaling()
{ {
QFETCH(QTransform, transform); QFETCH(QTransform, transform);
QBENCHMARK { QBENCHMARK {
transform.isScaling(); [[maybe_unused]] auto r = transform.isScaling();
} }
} }
@ -514,7 +514,7 @@ void tst_QTransform::isTranslating()
{ {
QFETCH(QTransform, transform); QFETCH(QTransform, transform);
QBENCHMARK { QBENCHMARK {
transform.isTranslating(); [[maybe_unused]] auto r = transform.isTranslating();
} }
} }
@ -524,7 +524,7 @@ void tst_QTransform::type()
{ {
QFETCH(QTransform, transform); QFETCH(QTransform, transform);
QBENCHMARK { QBENCHMARK {
transform.type(); [[maybe_unused]] auto r = transform.type();
} }
} }
@ -534,7 +534,7 @@ void tst_QTransform::determinant()
{ {
QFETCH(QTransform, transform); QFETCH(QTransform, transform);
QBENCHMARK { QBENCHMARK {
transform.determinant(); [[maybe_unused]] auto r = transform.determinant();
} }
} }