<br><br><div class="gmail_quote">On Thu, Dec 6, 2012 at 8:18 PM, Jordan Rose <span dir="ltr"><<a href="mailto:jordan_rose@apple.com" target="_blank">jordan_rose@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Nice!<br>
<div><div class="h5"><br>
On Dec 6, 2012, at 11:09 , Benjamin Kramer <<a href="mailto:benny.kra@googlemail.com">benny.kra@googlemail.com</a>> wrote:<br>
<br>
> Author: d0k<br>
> Date: Thu Dec  6 13:09:30 2012<br>
> New Revision: 169535<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=169535&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=169535&view=rev</a><br>
> Log:<br>
> Add move semantics to PartialDiagnostic, which can be very expensive to copy.<br>
><br>
> Modified:<br>
>    cfe/trunk/include/clang/Basic/PartialDiagnostic.h<br>
><br>
> Modified: cfe/trunk/include/clang/Basic/PartialDiagnostic.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/PartialDiagnostic.h?rev=169535&r1=169534&r2=169535&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/PartialDiagnostic.h?rev=169535&r1=169534&r2=169535&view=diff</a><br>

> ==============================================================================<br>
> --- cfe/trunk/include/clang/Basic/PartialDiagnostic.h (original)<br>
> +++ cfe/trunk/include/clang/Basic/PartialDiagnostic.h Thu Dec  6 13:09:30 2012<br>
> @@ -19,6 +19,7 @@<br>
> #include "clang/Basic/Diagnostic.h"<br>
> #include "clang/Basic/SourceLocation.h"<br>
> #include "llvm/ADT/STLExtras.h"<br>
> +#include "llvm/Support/Compiler.h"<br>
> #include "llvm/Support/DataTypes.h"<br>
> #include <cassert><br>
><br>
> @@ -200,6 +201,14 @@<br>
>     }<br>
>   }<br>
><br>
> +#if LLVM_HAS_RVALUE_REFERENCES<br>
> +  PartialDiagnostic(PartialDiagnostic &&Other)<br>
> +    : DiagID(Other.DiagID), DiagStorage(Other.DiagStorage),<br>
> +      Allocator(Other.Allocator) {<br>
> +    Other.DiagStorage = 0;<br>
> +  }<br>
> +#endif<br>
> +<br>
>   PartialDiagnostic(const PartialDiagnostic &Other, Storage *DiagStorage)<br>
>     : DiagID(Other.DiagID), DiagStorage(DiagStorage),<br>
>       Allocator(reinterpret_cast<StorageAllocator *>(~uintptr_t(0)))<br>
> @@ -242,6 +251,23 @@<br>
>     return *this;<br>
>   }<br>
><br>
> +#if LLVM_HAS_RVALUE_REFERENCES<br>
> +  PartialDiagnostic &operator=(PartialDiagnostic &&Other) {<br>
> +    if (this != &Other) {<br>
<br>
</div></div>Is this really necessary? If this is true, I think the move contract has been violated anyway.<br>
<div class="HOEnZb"><div class="h5">_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</div></div></blockquote></div><br>There was a discussion on stack overflow recently about this, and Howard chimed in: it is unnecessary.<br><br>On the other hand, a `assert(this != &Other && "Illegal attempt to move toward itself")` may make sense since this can quickly become a gotcha.<br>
<br>-- Matthieu<br>