Stop moving local objects in return statements
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Dec 2015 16:26:24 +0000 (16:26 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 28 Dec 2015 16:26:24 +0000 (16:26 +0000)
commite06c99729e8e84eba4b622f5f7531a23f9e91a8e
treecafe5518b1a13acc550f846756a4ac50246faf54
parentb4f478f567bb3899947c900fe17504e5f922f5f1
Stop moving local objects in return statements
https://bugs.webkit.org/show_bug.cgi?id=152557

Reviewed by Brady Eidson.

Source/JavaScriptCore:

Calling std::move() on a local object in a return statement prevents the compiler from applying the return value optimization.

Clang can warn about these mistakes with -Wpessimizing-move, although only when std::move() is called directly.
I found these issues by temporarily replacing WTF::move with std::move and recompiling.

* inspector/ScriptCallStack.cpp:
(Inspector::ScriptCallStack::buildInspectorArray):
* inspector/agents/InspectorScriptProfilerAgent.cpp:
(Inspector::buildInspectorObject):
* jit/CallFrameShuffler.h:
(JSC::CallFrameShuffler::snapshot):
* runtime/TypeSet.cpp:
(JSC::TypeSet::allStructureRepresentations):
(JSC::StructureShape::inspectorRepresentation):

Source/WebCore:

Calling std::move() on a local object in a return statement prevents the compiler from applying the return value optimization.

Clang can warn about these mistakes with -Wpessimizing-move, although only when std::move() is called directly.
I found these issues by temporarily replacing WTF::move with std::move and recompiling.

* Modules/indexeddb/IDBDatabaseIdentifier.cpp:
(WebCore::IDBDatabaseIdentifier::isolatedCopy):
* Modules/indexeddb/IDBKeyData.cpp:
(WebCore::IDBKeyData::deletedValue):
* Modules/indexeddb/client/IDBDatabaseImpl.cpp:
(WebCore::IDBClient::IDBDatabase::objectStoreNames):
(WebCore::IDBClient::IDBDatabase::startVersionChangeTransaction):
* Modules/indexeddb/client/IDBTransactionImpl.cpp:
(WebCore::IDBClient::IDBTransaction::createObjectStore):
(WebCore::IDBClient::IDBTransaction::createIndex):
(WebCore::IDBClient::IDBTransaction::doRequestOpenCursor):
(WebCore::IDBClient::IDBTransaction::requestGetRecord):
(WebCore::IDBClient::IDBTransaction::requestIndexRecord):
(WebCore::IDBClient::IDBTransaction::requestClearObjectStore):
(WebCore::IDBClient::IDBTransaction::requestPutOrAdd):
* Modules/indexeddb/server/UniqueIDBDatabase.cpp:
(WebCore::IDBServer::UniqueIDBDatabase::takeNextRunnableTransaction):
* Modules/indexeddb/shared/IDBDatabaseInfo.cpp:
(WebCore::IDBDatabaseInfo::isolatedCopy):
(WebCore::IDBDatabaseInfo::objectStoreNames):
* Modules/indexeddb/shared/IDBResultData.cpp:
(WebCore::IDBResultData::error):
(WebCore::IDBResultData::openDatabaseSuccess):
(WebCore::IDBResultData::openDatabaseUpgradeNeeded):
* Modules/indexeddb/shared/IDBTransactionInfo.cpp:
(WebCore::IDBTransactionInfo::versionChange):
(WebCore::IDBTransactionInfo::isolatedCopy):
* Modules/indexeddb/shared/InProcessIDBServer.cpp:
(WebCore::InProcessIDBServer::create):
* Modules/webaudio/OfflineAudioContext.cpp:
(WebCore::OfflineAudioContext::create):
* Modules/webdatabase/DatabaseTracker.cpp:
(WebCore::DatabaseTracker::originLockFor):
* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::create):
* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::formatNumberValue):
* dom/NodeOrString.cpp:
(WebCore::convertNodesOrStringsIntoNode):
* inspector/InspectorApplicationCacheAgent.cpp:
(WebCore::InspectorApplicationCacheAgent::buildArrayForApplicationCacheResources):
* inspector/InspectorDOMAgent.cpp:
(WebCore::InspectorDOMAgent::buildObjectForNode):
(WebCore::InspectorDOMAgent::buildArrayForElementAttributes):
(WebCore::InspectorDOMAgent::buildArrayForContainerChildren):
(WebCore::InspectorDOMAgent::buildObjectForEventListener):
* inspector/InspectorIndexedDBAgent.cpp:
* inspector/InspectorLayerTreeAgent.cpp:
(WebCore::InspectorLayerTreeAgent::buildObjectForLayer):
* inspector/InspectorNetworkAgent.cpp:
(WebCore::buildObjectForHeaders):
(WebCore::buildObjectForResourceRequest):
(WebCore::buildObjectForCachedResource):
* inspector/InspectorOverlay.cpp:
(WebCore::buildArrayForQuad):
(WebCore::buildObjectForFlowRegions):
(WebCore::InspectorOverlay::buildObjectForHighlightedNodes):
* inspector/InspectorPageAgent.cpp:
(WebCore::createXHRTextDecoder):
(WebCore::buildArrayForCookies):
(WebCore::InspectorPageAgent::buildObjectForFrame):
* inspector/InspectorStyleSheet.cpp:
(WebCore::buildMediaObject):
(WebCore::InspectorStyle::buildArrayForComputedStyle):
(WebCore::buildObjectForSelectorHelper):
(WebCore::selectorsFromSource):
(WebCore::InspectorStyleSheet::buildObjectForSelectorList):
(WebCore::InspectorStyleSheet::buildObjectForStyle):
(WebCore::InspectorStyleSheet::buildArrayForRuleList):
* inspector/InspectorTimelineAgent.cpp:
(WebCore::InspectorTimelineAgent::stopFromConsole):
* inspector/TimelineRecordFactory.cpp:
(WebCore::TimelineRecordFactory::createGenericRecord):
(WebCore::TimelineRecordFactory::createFunctionCallData):
(WebCore::TimelineRecordFactory::createConsoleProfileData):
(WebCore::TimelineRecordFactory::createProbeSampleData):
(WebCore::TimelineRecordFactory::createEventDispatchData):
(WebCore::TimelineRecordFactory::createGenericTimerData):
(WebCore::TimelineRecordFactory::createTimerInstallData):
(WebCore::TimelineRecordFactory::createEvaluateScriptData):
(WebCore::TimelineRecordFactory::createTimeStampData):
(WebCore::TimelineRecordFactory::createAnimationFrameData):
(WebCore::createQuad):
(WebCore::TimelineRecordFactory::createPaintData):
(WebCore::buildInspectorObject):
* loader/FrameLoader.cpp:
(WebCore::createWindow):
* loader/NavigationAction.cpp:
(WebCore::NavigationAction::copyWithShouldOpenExternalURLsPolicy):
* page/DOMWindow.cpp:
(WebCore::DOMWindow::createWindow):
* platform/network/ios/QuickLook.mm:
(WebCore::QuickLookHandle::create):
* testing/Internals.cpp:
(WebCore::Internals::openDummyInspectorFrontend):
* workers/WorkerScriptLoader.cpp:
(WebCore::WorkerScriptLoader::createResourceRequest):
* xml/XPathExpression.cpp:
(WebCore::XPathExpression::evaluate):

Source/WebKit2:

Calling std::move() on a local object in a return statement prevents the compiler from applying the return value optimization.

Clang can warn about these mistakes with -Wpessimizing-move, although only when std::move() is called directly.
I found these issues by temporarily replacing WTF::move with std::move and recompiling.

* UIProcess/WebPageProxy.cpp:
(WebKit::ExceededDatabaseQuotaRecords::createRecord):

Source/WTF:

* wtf/StdLibExtras.h: Added a FIXME about how using WTF::move() prevents several Clang diagnostics from emitting useful warnings.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@194428 268f45cc-cd09-0410-ab3c-d52691b4dbfc
41 files changed:
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/ScriptCallStack.cpp
Source/JavaScriptCore/inspector/agents/InspectorScriptProfilerAgent.cpp
Source/JavaScriptCore/jit/CallFrameShuffler.h
Source/JavaScriptCore/runtime/TypeSet.cpp
Source/WTF/ChangeLog
Source/WTF/wtf/StdLibExtras.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/indexeddb/IDBDatabaseIdentifier.cpp
Source/WebCore/Modules/indexeddb/IDBKeyData.cpp
Source/WebCore/Modules/indexeddb/client/IDBDatabaseImpl.cpp
Source/WebCore/Modules/indexeddb/client/IDBTransactionImpl.cpp
Source/WebCore/Modules/indexeddb/server/UniqueIDBDatabase.cpp
Source/WebCore/Modules/indexeddb/shared/IDBDatabaseInfo.cpp
Source/WebCore/Modules/indexeddb/shared/IDBResultData.cpp
Source/WebCore/Modules/indexeddb/shared/IDBTransactionInfo.cpp
Source/WebCore/Modules/indexeddb/shared/InProcessIDBServer.cpp
Source/WebCore/Modules/webaudio/OfflineAudioContext.cpp
Source/WebCore/Modules/webdatabase/DatabaseTracker.cpp
Source/WebCore/Modules/websockets/WebSocket.cpp
Source/WebCore/css/CSSPrimitiveValue.cpp
Source/WebCore/dom/NodeOrString.cpp
Source/WebCore/inspector/InspectorApplicationCacheAgent.cpp
Source/WebCore/inspector/InspectorDOMAgent.cpp
Source/WebCore/inspector/InspectorIndexedDBAgent.cpp
Source/WebCore/inspector/InspectorLayerTreeAgent.cpp
Source/WebCore/inspector/InspectorNetworkAgent.cpp
Source/WebCore/inspector/InspectorOverlay.cpp
Source/WebCore/inspector/InspectorPageAgent.cpp
Source/WebCore/inspector/InspectorStyleSheet.cpp
Source/WebCore/inspector/InspectorTimelineAgent.cpp
Source/WebCore/inspector/TimelineRecordFactory.cpp
Source/WebCore/loader/FrameLoader.cpp
Source/WebCore/loader/NavigationAction.cpp
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/platform/network/ios/QuickLook.mm
Source/WebCore/testing/Internals.cpp
Source/WebCore/workers/WorkerScriptLoader.cpp
Source/WebCore/xml/XPathExpression.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/WebPageProxy.cpp