Commit 3efb8b2 1 parent 833687b commit 3efb8b2 Copy full SHA for 3efb8b2
File tree 3 files changed +49
-10
lines changed
3 files changed +49
-10
lines changed Original file line number Diff line number Diff line change @@ -30,18 +30,12 @@ class APSInt : public APInt {
30
30
explicit APSInt (uint32_t BitWidth, bool isUnsigned = true )
31
31
: APInt(BitWidth, 0 ), IsUnsigned(isUnsigned) {}
32
32
33
- explicit APSInt (const APInt & I, bool isUnsigned = true )
34
- : APInt(I ), IsUnsigned(isUnsigned) {}
33
+ explicit APSInt (APInt I, bool isUnsigned = true )
34
+ : APInt(std::move(I) ), IsUnsigned(isUnsigned) {}
35
35
36
- APSInt &operator =(const APSInt &RHS) {
37
- APInt::operator =(RHS);
38
- IsUnsigned = RHS.IsUnsigned ;
39
- return *this ;
40
- }
41
-
42
- APSInt &operator =(const APInt &RHS) {
36
+ APSInt &operator =(APInt RHS) {
43
37
// Retain our current sign.
44
- APInt::operator =(RHS);
38
+ APInt::operator =(std::move ( RHS) );
45
39
return *this ;
46
40
}
47
41
Original file line number Diff line number Diff line change
1
+ // ===- llvm/unittest/ADT/APSIntTest.cpp - APSInt unit tests ---------------===//
2
+ //
3
+ // The LLVM Compiler Infrastructure
4
+ //
5
+ // This file is distributed under the University of Illinois Open Source
6
+ // License. See LICENSE.TXT for details.
7
+ //
8
+ // ===----------------------------------------------------------------------===//
9
+
10
+ #include " llvm/ADT/APSInt.h"
11
+ #include " gtest/gtest.h"
12
+
13
+ using namespace llvm ;
14
+
15
+ namespace {
16
+
17
+ TEST (APSIntTest, MoveTest) {
18
+ APSInt A (32 , true );
19
+ EXPECT_TRUE (A.isUnsigned ());
20
+
21
+ APSInt B (128 , false );
22
+ A = B;
23
+ EXPECT_FALSE (A.isUnsigned ());
24
+
25
+ APSInt C (B);
26
+ EXPECT_FALSE (C.isUnsigned ());
27
+
28
+ APInt Wide (256 , 0 );
29
+ const uint64_t *Bits = Wide.getRawData ();
30
+ APSInt D (std::move (Wide));
31
+ EXPECT_TRUE (D.isUnsigned ());
32
+ EXPECT_EQ (Bits, D.getRawData ()); // Verify that "Wide" was really moved.
33
+
34
+ A = APSInt (64 , true );
35
+ EXPECT_TRUE (A.isUnsigned ());
36
+
37
+ Wide = APInt (128 , 1 );
38
+ Bits = Wide.getRawData ();
39
+ A = std::move (Wide);
40
+ EXPECT_TRUE (A.isUnsigned ());
41
+ EXPECT_EQ (Bits, A.getRawData ()); // Verify that "Wide" was really moved.
42
+ }
43
+
44
+ }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ set(LLVM_LINK_COMPONENTS
5
5
set (ADTSources
6
6
APFloatTest.cpp
7
7
APIntTest.cpp
8
+ APSIntTest.cpp
8
9
ArrayRefTest.cpp
9
10
BitVectorTest.cpp
10
11
DAGDeltaAlgorithmTest.cpp
You can’t perform that action at this time.
0 commit comments