From 672bee2ed1172fcb024093d5698a1c81cac5f38c Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Wed, 30 Jan 2019 20:54:57 +0100 Subject: [PATCH] Don't detach temporaries [-Wclazy-detaching-temporary] Change-Id: I278873fff8592249f0c4519a4e4a6faff2dff6e3 Reviewed-by: Orgad Shaneh --- .../clangtoolspreconfiguredsessiontests.cpp | 2 +- .../clangtools/clangtoolsunittests.cpp | 2 +- .../followsymbol_switchmethoddecldef_test.cpp | 2 +- .../valgrind/valgrindtestrunnertest.cpp | 76 +++++++++---------- src/plugins/vcsbase/vcsbaseeditor.cpp | 2 +- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/src/plugins/clangtools/clangtoolspreconfiguredsessiontests.cpp b/src/plugins/clangtools/clangtoolspreconfiguredsessiontests.cpp index 6014e008219..e31522f3719 100644 --- a/src/plugins/clangtools/clangtoolspreconfiguredsessiontests.cpp +++ b/src/plugins/clangtools/clangtoolspreconfiguredsessiontests.cpp @@ -223,7 +223,7 @@ bool PreconfiguredSessionTests::switchToProjectAndTarget(Project *project, SessionManager::setActiveTarget(project, target, ProjectExplorer::SetActive::NoCascade); QTC_ASSERT(spyFinishedParsing.wait(30000), return false); - const QVariant projectArgument = spyFinishedParsing.takeFirst().takeFirst(); + const QVariant projectArgument = spyFinishedParsing.takeFirst().constFirst(); QTC_ASSERT(projectArgument.canConvert(), return false); return projectArgument.value() == project; diff --git a/src/plugins/clangtools/clangtoolsunittests.cpp b/src/plugins/clangtools/clangtoolsunittests.cpp index 7cf401aa0e6..3e5d716116c 100644 --- a/src/plugins/clangtools/clangtoolsunittests.cpp +++ b/src/plugins/clangtools/clangtoolsunittests.cpp @@ -94,7 +94,7 @@ void ClangToolsUnitTests::testProject() QFETCH(int, expectedDiagCount); if (projectFilePath.contains("mingw")) { const ToolChain * const toolchain - = ToolChainKitInformation::toolChain(KitManager::kits().first(), + = ToolChainKitInformation::toolChain(KitManager::kits().constFirst(), Constants::CXX_LANGUAGE_ID); if (toolchain->typeId() != ProjectExplorer::Constants::MINGW_TOOLCHAIN_TYPEID) QSKIP("This test is mingw specific, does not run for other toolchains"); diff --git a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp index 8d30cfbd437..5a82792ad8d 100644 --- a/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp +++ b/src/plugins/cppeditor/followsymbol_switchmethoddecldef_test.cpp @@ -102,7 +102,7 @@ QT_BEGIN_NAMESPACE namespace QTest { template<> char *toString(const OverrideItem &data) { - return qstrdup(data.toByteArray().data()); + return qstrdup(data.toByteArray().constData()); } } diff --git a/src/plugins/valgrind/valgrindtestrunnertest.cpp b/src/plugins/valgrind/valgrindtestrunnertest.cpp index d4f519e3527..4a3414060ef 100644 --- a/src/plugins/valgrind/valgrindtestrunnertest.cpp +++ b/src/plugins/valgrind/valgrindtestrunnertest.cpp @@ -160,7 +160,7 @@ void ValgrindTestRunnerTest::testLeak1() QCOMPARE(error.leakedBlocks(), qint64(1)); QCOMPARE(error.leakedBytes(), quint64(8)); QCOMPARE(error.stacks().count(), 1); - const Stack stack = error.stacks().first(); + const Stack stack = error.stacks().constFirst(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 2); { @@ -195,7 +195,7 @@ void ValgrindTestRunnerTest::testLeak2() QCOMPARE(error.leakedBlocks(), qint64(1)); QCOMPARE(error.leakedBytes(), quint64(5)); QCOMPARE(error.stacks().count(), 1); - const Stack stack = error.stacks().first(); + const Stack stack = error.stacks().constFirst(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 3); { @@ -235,7 +235,7 @@ void ValgrindTestRunnerTest::testLeak3() QCOMPARE(error.leakedBlocks(), qint64(1)); QCOMPARE(error.leakedBytes(), quint64(5)); QCOMPARE(error.stacks().count(), 1); - const Stack stack = error.stacks().first(); + const Stack stack = error.stacks().constFirst(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 3); { @@ -284,7 +284,7 @@ void ValgrindTestRunnerTest::testLeak4() QCOMPARE(error.leakedBlocks(), qint64(1)); QCOMPARE(error.leakedBytes(), quint64(8)); QCOMPARE(error.stacks().count(), 1); - const Stack stack = error.stacks().first(); + const Stack stack = error.stacks().constFirst(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 3); { @@ -325,7 +325,7 @@ void ValgrindTestRunnerTest::testLeak4() else QCOMPARE(error.leakedBytes(), quint64(12)); QCOMPARE(error.stacks().count(), 1); - const Stack stack = error.stacks().first(); + const Stack stack = error.stacks().constFirst(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 2); { @@ -364,11 +364,11 @@ void ValgrindTestRunnerTest::testUninit1() QCOMPARE(error.stacks().count(), 2); //BEGIN first stack { - const Stack stack = error.stacks().first(); + const Stack stack = error.stacks().constFirst(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 1); - const Frame frame = stack.frames().first(); + const Frame frame = stack.frames().constFirst(); QCOMPARE(frame.functionName(), QString("main")); QCOMPARE(frame.line(), 4 + HEADER_LENGTH); @@ -378,11 +378,11 @@ void ValgrindTestRunnerTest::testUninit1() } //BEGIN second stack { - const Stack stack = error.stacks().last(); + const Stack stack = error.stacks().constLast(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 1); - const Frame frame = stack.frames().first(); + const Frame frame = stack.frames().constFirst(); QCOMPARE(frame.functionName(), QString("main")); QCOMPARE(frame.line(), 2 + HEADER_LENGTH); @@ -412,11 +412,11 @@ void ValgrindTestRunnerTest::testUninit2() QCOMPARE(error.stacks().count(), 2); //BEGIN first stack { - const Stack stack = error.stacks().first(); + const Stack stack = error.stacks().constFirst(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 1); - const Frame frame = stack.frames().first(); + const Frame frame = stack.frames().constFirst(); QCOMPARE(frame.functionName(), QString("main")); QCOMPARE(frame.line(), 4 + HEADER_LENGTH); @@ -426,11 +426,11 @@ void ValgrindTestRunnerTest::testUninit2() } //BEGIN second stack { - const Stack stack = error.stacks().last(); + const Stack stack = error.stacks().constLast(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 1); - const Frame frame = stack.frames().first(); + const Frame frame = stack.frames().constFirst(); QCOMPARE(frame.functionName(), QString("main")); QCOMPARE(frame.line(), 2 + HEADER_LENGTH); @@ -445,11 +445,11 @@ void ValgrindTestRunnerTest::testUninit2() QCOMPARE(error.kind(), int(InvalidWrite)); QCOMPARE(error.stacks().count(), 1); - const Stack stack = error.stacks().first(); + const Stack stack = error.stacks().constFirst(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 1); - const Frame frame = stack.frames().first(); + const Frame frame = stack.frames().constFirst(); QCOMPARE(frame.functionName(), QString("main")); QCOMPARE(frame.line(), 4 + HEADER_LENGTH); @@ -479,11 +479,11 @@ void ValgrindTestRunnerTest::testUninit3() QCOMPARE(error.stacks().count(), 2); //BEGIN first stack { - const Stack stack = error.stacks().first(); + const Stack stack = error.stacks().constFirst(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 1); - const Frame frame = stack.frames().first(); + const Frame frame = stack.frames().constFirst(); QCOMPARE(frame.functionName(), QString("main")); QCOMPARE(frame.line(), 4 + HEADER_LENGTH); @@ -493,11 +493,11 @@ void ValgrindTestRunnerTest::testUninit3() } //BEGIN second stack { - const Stack stack = error.stacks().last(); + const Stack stack = error.stacks().constLast(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 1); - const Frame frame = stack.frames().first(); + const Frame frame = stack.frames().constFirst(); QCOMPARE(frame.functionName(), QString("main")); QCOMPARE(frame.line(), 2 + HEADER_LENGTH); @@ -512,11 +512,11 @@ void ValgrindTestRunnerTest::testUninit3() QCOMPARE(error.kind(), int(InvalidRead)); QCOMPARE(error.stacks().count(), 1); - const Stack stack = error.stacks().first(); + const Stack stack = error.stacks().constFirst(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 1); - const Frame frame = stack.frames().first(); + const Frame frame = stack.frames().constFirst(); QCOMPARE(frame.functionName(), QString("main")); QCOMPARE(frame.line(), 4 + HEADER_LENGTH); @@ -543,7 +543,7 @@ void ValgrindTestRunnerTest::testSyscall() QCOMPARE(error.stacks().count(), 2); //BEGIN first stack { - const Stack stack = error.stacks().first(); + const Stack stack = error.stacks().constFirst(); QCOMPARE(stack.line(), qint64(-1)); if (on64bit()) { QCOMPARE(stack.frames().count(), 4); @@ -574,11 +574,11 @@ void ValgrindTestRunnerTest::testSyscall() } //BEGIN second stack { - const Stack stack = error.stacks().last(); + const Stack stack = error.stacks().constLast(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 1); - const Frame frame = stack.frames().first(); + const Frame frame = stack.frames().constFirst(); QCOMPARE(frame.functionName(), QString("main")); QCOMPARE(frame.line(), 2 + HEADER_LENGTH); @@ -605,16 +605,16 @@ void ValgrindTestRunnerTest::testFree1() QVERIFY(error.stacks().count() >= 2); //BEGIN first stack { - const Stack stack = error.stacks().first(); + const Stack stack = error.stacks().constFirst(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 2); { - const Frame frame = stack.frames().first(); + const Frame frame = stack.frames().constFirst(); QCOMPARE(frame.functionName(), QString("operator delete(void*)")); } { - const Frame frame = stack.frames().last(); + const Frame frame = stack.frames().constLast(); QCOMPARE(frame.functionName(), QString("main")); QCOMPARE(frame.line(), 7 + HEADER_LENGTH); @@ -630,11 +630,11 @@ void ValgrindTestRunnerTest::testFree1() QCOMPARE(stack.frames().count(), 2); { - const Frame frame = stack.frames().first(); + const Frame frame = stack.frames().constFirst(); QCOMPARE(frame.functionName(), QString("operator delete(void*)")); } { - const Frame frame = stack.frames().last(); + const Frame frame = stack.frames().constLast(); QCOMPARE(frame.functionName(), QString("main")); QCOMPARE(frame.line(), 6 + HEADER_LENGTH); @@ -662,16 +662,16 @@ void ValgrindTestRunnerTest::testFree2() QCOMPARE(error.stacks().count(), 2); //BEGIN first stack { - const Stack stack = error.stacks().first(); + const Stack stack = error.stacks().constFirst(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 2); { - const Frame frame = stack.frames().first(); + const Frame frame = stack.frames().constFirst(); QCOMPARE(frame.functionName(), QString("free")); } { - const Frame frame = stack.frames().last(); + const Frame frame = stack.frames().constLast(); QCOMPARE(frame.functionName(), QString("main")); QCOMPARE(frame.line(), 6 + HEADER_LENGTH); @@ -682,20 +682,20 @@ void ValgrindTestRunnerTest::testFree2() } //BEGIN second stack { - const Stack stack = error.stacks().last(); + const Stack stack = error.stacks().constLast(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 2); { - const Frame frame = stack.frames().first(); + const Frame frame = stack.frames().constFirst(); if (on64bit()) QCOMPARE(frame.functionName(), QString("operator new(unsigned long)")); else QCOMPARE(frame.functionName(), QString("operator new(unsigned int)")); } { - const Frame frame = stack.frames().last(); + const Frame frame = stack.frames().constLast(); QCOMPARE(frame.functionName(), QString("main")); QCOMPARE(frame.line(), 5 + HEADER_LENGTH); @@ -721,7 +721,7 @@ void ValgrindTestRunnerTest::testInvalidjump() const Error error = m_errors.first(); QCOMPARE(error.kind(), int(InvalidJump)); QCOMPARE(error.stacks().count(), 1); - const Stack stack = error.stacks().first(); + const Stack stack = error.stacks().constFirst(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 2); QVERIFY(!stack.auxWhat().isEmpty()); @@ -751,7 +751,7 @@ void ValgrindTestRunnerTest::testOverlap() const Error error = m_errors.first(); QCOMPARE(error.kind(), int(Overlap)); QCOMPARE(error.stacks().count(), 1); - const Stack stack = error.stacks().first(); + const Stack stack = error.stacks().constFirst(); QCOMPARE(stack.line(), qint64(-1)); QCOMPARE(stack.frames().count(), 2); { @@ -759,7 +759,7 @@ void ValgrindTestRunnerTest::testOverlap() QVERIFY(frame.functionName().startsWith("memcpy")); } { - const Frame frame = stack.frames().last(); + const Frame frame = stack.frames().constLast(); QCOMPARE(frame.functionName(), QLatin1String("main")); QCOMPARE(frame.line(), 6 + HEADER_LENGTH); diff --git a/src/plugins/vcsbase/vcsbaseeditor.cpp b/src/plugins/vcsbase/vcsbaseeditor.cpp index 0c46e20cbdc..6fcfd09eae0 100644 --- a/src/plugins/vcsbase/vcsbaseeditor.cpp +++ b/src/plugins/vcsbase/vcsbaseeditor.cpp @@ -1621,7 +1621,7 @@ Core::IEditor *VcsBaseEditor::locateEditorByTag(const QString &tag) foreach (Core::IDocument *document, Core::DocumentModel::openedDocuments()) { const QVariant tagPropertyValue = document->property(tagPropertyC); if (tagPropertyValue.type() == QVariant::String && tagPropertyValue.toString() == tag) - return Core::DocumentModel::editorsForDocument(document).first(); + return Core::DocumentModel::editorsForDocument(document).constFirst(); } return nullptr; }