APInt: Make self-move-assignment a no-op to fix stage3 clang-cl
authorReid Kleckner <reid@kleckner.net>
Tue, 12 Aug 2014 22:01:39 +0000 (22:01 +0000)
committerReid Kleckner <reid@kleckner.net>
Tue, 12 Aug 2014 22:01:39 +0000 (22:01 +0000)
commit151f8cef7470e89843a43359850d1cb4159ba3e3
tree25850f2c54589a74601aab399ccf61e72cea01b5
parentee8b879822d3a17025a614a95420b3cf3c0e424a
APInt: Make self-move-assignment a no-op to fix stage3 clang-cl

It's not clear what the semantics of a self-move should be.  The
consensus appears to be that a self-move should leave the object in a
moved-from state, which is what our existing move assignment operator
does.

However, the MSVC 2013 STL will perform self-moves in some cases.  In
particular, when doing a std::stable_sort of an already sorted APSInt
vector of an appropriate size, one of the merge steps will self-move
half of the elements.

We don't notice this when building with MSVC, because MSVC will not
synthesize the move assignment operator for APSInt.  Presumably MSVC
does this because APInt, the base class, has user-declared special
members that implicitly delete move special members.  Instead, MSVC
selects the copy-assign operator, which defends against self-assignment.
Clang, on the other hand, selects the move-assign operator, and we get
garbage APInts.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215478 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/ADT/APInt.h
unittests/ADT/APIntTest.cpp