QTestLib: Fix various clang warnings
- Fix else after return/break - Fix use of int as boolean literal - Use range-based for in some cases - Avoid copies by using const-ref - Remove unnecessary null-check before delete Task-number: QTBUG-69413 Change-Id: I69f46e6deaa55ef70a8b3a61e6539c79a64aaa23 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This commit is contained in:
parent
afb8ba3fd2
commit
111df3b5e0
@ -66,8 +66,7 @@ void QBenchmarkGlobalData::setMode(Mode mode)
|
|||||||
{
|
{
|
||||||
mode_ = mode;
|
mode_ = mode;
|
||||||
|
|
||||||
if (measurer)
|
delete measurer;
|
||||||
delete measurer;
|
|
||||||
measurer = createMeasurer();
|
measurer = createMeasurer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -98,11 +97,8 @@ QBenchmarkMeasurerBase * QBenchmarkGlobalData::createMeasurer()
|
|||||||
|
|
||||||
int QBenchmarkGlobalData::adjustMedianIterationCount()
|
int QBenchmarkGlobalData::adjustMedianIterationCount()
|
||||||
{
|
{
|
||||||
if (medianIterationCount != -1) {
|
return medianIterationCount != -1
|
||||||
return medianIterationCount;
|
? medianIterationCount : measurer->adjustMedianCount(1);
|
||||||
} else {
|
|
||||||
return measurer->adjustMedianCount(1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ public:
|
|||||||
virtual bool isMeasurementAccepted(qint64 measurement) = 0;
|
virtual bool isMeasurementAccepted(qint64 measurement) = 0;
|
||||||
virtual int adjustIterationCount(int suggestion) = 0;
|
virtual int adjustIterationCount(int suggestion) = 0;
|
||||||
virtual int adjustMedianCount(int suggestion) = 0;
|
virtual int adjustMedianCount(int suggestion) = 0;
|
||||||
virtual bool repeatCount() { return 1; }
|
virtual bool repeatCount() { return true; }
|
||||||
virtual bool needsWarmupIteration() { return false; }
|
virtual bool needsWarmupIteration() { return false; }
|
||||||
virtual QTest::QBenchmarkMetric metricType() = 0;
|
virtual QTest::QBenchmarkMetric metricType() = 0;
|
||||||
};
|
};
|
||||||
|
@ -67,7 +67,7 @@ public:
|
|||||||
bool isMeasurementAccepted(qint64 measurement) override;
|
bool isMeasurementAccepted(qint64 measurement) override;
|
||||||
int adjustIterationCount(int suggestion) override;
|
int adjustIterationCount(int suggestion) override;
|
||||||
int adjustMedianCount(int suggestion) override;
|
int adjustMedianCount(int suggestion) override;
|
||||||
bool repeatCount() override { return 1; }
|
bool repeatCount() override { return true; }
|
||||||
bool needsWarmupIteration() override { return true; }
|
bool needsWarmupIteration() override { return true; }
|
||||||
QTest::QBenchmarkMetric metricType() override;
|
QTest::QBenchmarkMetric metricType() override;
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ QString QBenchmarkValgrindUtils::outFileBase(qint64 pid)
|
|||||||
// Returns \c true upon success, otherwise false.
|
// Returns \c true upon success, otherwise false.
|
||||||
bool QBenchmarkValgrindUtils::runCallgrindSubProcess(const QStringList &origAppArgs, int &exitCode)
|
bool QBenchmarkValgrindUtils::runCallgrindSubProcess(const QStringList &origAppArgs, int &exitCode)
|
||||||
{
|
{
|
||||||
const QString execFile(origAppArgs.at(0));
|
const QString &execFile = origAppArgs.at(0);
|
||||||
QStringList args;
|
QStringList args;
|
||||||
args << QLatin1String("--tool=callgrind") << QLatin1String("--instr-atstart=yes")
|
args << QLatin1String("--tool=callgrind") << QLatin1String("--instr-atstart=yes")
|
||||||
<< QLatin1String("--quiet")
|
<< QLatin1String("--quiet")
|
||||||
@ -177,7 +177,7 @@ bool QBenchmarkValgrindUtils::runCallgrindSubProcess(const QStringList &origAppA
|
|||||||
// pass on original arguments that make sense (e.g. avoid wasting time producing output
|
// pass on original arguments that make sense (e.g. avoid wasting time producing output
|
||||||
// that will be ignored anyway) ...
|
// that will be ignored anyway) ...
|
||||||
for (int i = 1; i < origAppArgs.size(); ++i) {
|
for (int i = 1; i < origAppArgs.size(); ++i) {
|
||||||
const QString arg(origAppArgs.at(i));
|
const QString &arg = origAppArgs.at(i);
|
||||||
if (arg == QLatin1String("-callgrind"))
|
if (arg == QLatin1String("-callgrind"))
|
||||||
continue;
|
continue;
|
||||||
args << arg; // ok to pass on
|
args << arg; // ok to pass on
|
||||||
|
@ -222,9 +222,7 @@ QString QTeamCityLogger::tcEscapedString(const QString &str) const
|
|||||||
{
|
{
|
||||||
QString formattedString;
|
QString formattedString;
|
||||||
|
|
||||||
for (int i = 0; i < str.length(); i++) {
|
for (QChar ch : str) {
|
||||||
QChar ch = str.at(i);
|
|
||||||
|
|
||||||
switch (ch.toLatin1()) {
|
switch (ch.toLatin1()) {
|
||||||
case '\n':
|
case '\n':
|
||||||
formattedString.append(QLatin1String("|n"));
|
formattedString.append(QLatin1String("|n"));
|
||||||
|
@ -210,11 +210,10 @@ static bool checkCondition(const QByteArray &condition)
|
|||||||
static const QSet<QByteArray> matchedConditions = activeConditions();
|
static const QSet<QByteArray> matchedConditions = activeConditions();
|
||||||
QList<QByteArray> conds = condition.split(' ');
|
QList<QByteArray> conds = condition.split(' ');
|
||||||
|
|
||||||
for (int i = 0; i < conds.size(); ++i) {
|
for (QByteArray c : conds) {
|
||||||
QByteArray c = conds.at(i);
|
|
||||||
bool result = c.startsWith('!');
|
bool result = c.startsWith('!');
|
||||||
if (result)
|
if (result)
|
||||||
c = c.mid(1);
|
c.remove(0, 1);
|
||||||
|
|
||||||
result ^= matchedConditions.contains(c);
|
result ^= matchedConditions.contains(c);
|
||||||
if (!result)
|
if (!result)
|
||||||
|
@ -1040,7 +1040,7 @@ public:
|
|||||||
void run() override {
|
void run() override {
|
||||||
QMutexLocker locker(&mutex);
|
QMutexLocker locker(&mutex);
|
||||||
waitCondition.wakeAll();
|
waitCondition.wakeAll();
|
||||||
while (1) {
|
while (true) {
|
||||||
int t = timeout.loadRelaxed();
|
int t = timeout.loadRelaxed();
|
||||||
if (!t)
|
if (!t)
|
||||||
break;
|
break;
|
||||||
@ -1273,10 +1273,8 @@ char *toHexRepresentation(const char *ba, int length)
|
|||||||
++o;
|
++o;
|
||||||
if (i == len)
|
if (i == len)
|
||||||
break;
|
break;
|
||||||
else {
|
result[o] = ' ';
|
||||||
result[o] = ' ';
|
++o;
|
||||||
++o;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -180,23 +180,20 @@ inline static bool isEmpty(const char *str)
|
|||||||
static const char *incidentFormatString(bool noDescription, bool noTag)
|
static const char *incidentFormatString(bool noDescription, bool noTag)
|
||||||
{
|
{
|
||||||
if (noDescription) {
|
if (noDescription) {
|
||||||
if (noTag)
|
return noTag
|
||||||
return "<Incident type=\"%s\" file=\"%s\" line=\"%d\" />\n";
|
? "<Incident type=\"%s\" file=\"%s\" line=\"%d\" />\n"
|
||||||
else
|
: "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
|
||||||
return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
|
|
||||||
" <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n"
|
" <DataTag><![CDATA[%s%s%s%s]]></DataTag>\n"
|
||||||
"</Incident>\n";
|
"</Incident>\n";
|
||||||
} else {
|
|
||||||
if (noTag)
|
|
||||||
return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
|
|
||||||
" <Description><![CDATA[%s%s%s%s]]></Description>\n"
|
|
||||||
"</Incident>\n";
|
|
||||||
else
|
|
||||||
return "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
|
|
||||||
" <DataTag><![CDATA[%s%s%s]]></DataTag>\n"
|
|
||||||
" <Description><![CDATA[%s]]></Description>\n"
|
|
||||||
"</Incident>\n";
|
|
||||||
}
|
}
|
||||||
|
return noTag
|
||||||
|
? "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
|
||||||
|
" <Description><![CDATA[%s%s%s%s]]></Description>\n"
|
||||||
|
"</Incident>\n"
|
||||||
|
: "<Incident type=\"%s\" file=\"%s\" line=\"%d\">\n"
|
||||||
|
" <DataTag><![CDATA[%s%s%s]]></DataTag>\n"
|
||||||
|
" <Description><![CDATA[%s]]></Description>\n"
|
||||||
|
"</Incident>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *benchmarkResultFormatString()
|
static const char *benchmarkResultFormatString()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user