diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-06-02 08:39:08 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-06-02 08:39:08 +0000 |
commit | 0fa2b7b90df9a20baf2d14b7bc4fe7db5144efde (patch) | |
tree | d7edcbda75df917db03cd8b8a902559382411e0a | |
parent | 4524dd7518288f3d49bcaf31cff27cb82462c79c (diff) |
Add move semantics to APInt.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@157883 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/llvm/ADT/APInt.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/include/llvm/ADT/APInt.h b/include/llvm/ADT/APInt.h index eb7192cb95..75c1d576a6 100644 --- a/include/llvm/ADT/APInt.h +++ b/include/llvm/ADT/APInt.h @@ -16,6 +16,7 @@ #define LLVM_APINT_H #include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/MathExtras.h" #include <cassert> #include <climits> @@ -273,6 +274,13 @@ public: initSlowCase(that); } +#if LLVM_USE_RVALUE_REFERENCES + /// @brief Move Constructor. + APInt(APInt&& that) : BitWidth(that.BitWidth), VAL(that.VAL) { + that.BitWidth = 0; + } +#endif + /// @brief Destructor. ~APInt() { if (!isSingleWord()) @@ -587,6 +595,21 @@ public: return AssignSlowCase(RHS); } +#if LLVM_USE_RVALUE_REFERENCES + /// @brief Move assignment operator. + APInt& operator=(APInt&& that) { + if (!isSingleWord()) + delete [] pVal; + + BitWidth = that.BitWidth; + VAL = that.VAL; + + that.BitWidth = 0; + + return *this; + } +#endif + /// The RHS value is assigned to *this. If the significant bits in RHS exceed /// the bit width, the excess bits are truncated. If the bit width is larger /// than 64, the value is zero filled in the unspecified high order bits. |