<html>
<head>
<base href="https://bugs.webkit.org/" />
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - Use of WTF::move prevents clang's move diagnostics from warning about several classes of mistakes"
href="https://bugs.webkit.org/show_bug.cgi?id=152601">152601</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>Use of WTF::move prevents clang's move diagnostics from warning about several classes of mistakes
</td>
</tr>
<tr>
<th>Classification</th>
<td>Unclassified
</td>
</tr>
<tr>
<th>Product</th>
<td>WebKit
</td>
</tr>
<tr>
<th>Version</th>
<td>WebKit Nightly Build
</td>
</tr>
<tr>
<th>Hardware</th>
<td>All
</td>
</tr>
<tr>
<th>OS</th>
<td>All
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>Normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P2
</td>
</tr>
<tr>
<th>Component</th>
<td>Web Template Framework
</td>
</tr>
<tr>
<th>Assignee</th>
<td>webkit-unassigned@lists.webkit.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>aestes@apple.com
</td>
</tr></table>
<p>
<div>
<pre>Clang has recently added warnings to catch certain classes of mistakes with the use of std::move(): -Wpessimizing-move (warns if moving prevents copy elision), -Wredundant-move (warns if a move is redundant), and -Wself-move (warns if moving to self). Enabling these warnings manually (by renaming WTF::move to std::move) have caught numerous mistakes in our codebase (see <a href="http://trac.webkit.org/changeset/194428">http://trac.webkit.org/changeset/194428</a>).
It would be nice to be able to take advantage of these warnings, but doing so requires that we use std::move, not WTF::move. But since WTF::move does provide useful checks for which clang does not yet have warnings, we should find a way to write a best-of-both-worlds move function. I think we could do this like so:
namespace WTF {
enum CheckMoveParameterTag { CheckMoveParameter };
}
namespace std {
template<WTF::CheckMoveParameterTag, typename T>
ALWAYS_INLINE CONSTEXPR typename remove_reference<T>::type&& move(T&& value)
{
// static_asserts from WTF::move
return std::move(std::forward<T>(value));
}
}
#define WTF_MOVE(value) std::move<WTF::CheckMoveParameter>(value)
This move function satisfies clang's criteria for a move function (in namespace std, called "move", takes a single argument), but allows us to add our own compile-time asserts to check for moving from const and moving from rvalue reference. A macro called WTF_MOVE() is added for convenience.
I plan to address this in two stages:
1. Upload a patch that defines std::move<WTF::CheckMoveParameter>() and WTF_MOVE().
2. Upload a patch that removes WTF::move and renames all uses of WTF::move to WTF_MOVE.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>