@@ -64,53 +64,53 @@ Pointer::~Pointer() {
64
64
}
65
65
66
66
void Pointer::operator =(const Pointer &P) {
67
- if (!this ->isIntegralPointer () || !P.isBlockPointer ())
68
- assert (P.StorageKind == StorageKind || (this ->isZero () && P.isZero ()));
69
-
67
+ // If the current storage type is Block, we need to remove
68
+ // this pointer from the block.
70
69
bool WasBlockPointer = isBlockPointer ();
71
- StorageKind = P.StorageKind ;
72
70
if (StorageKind == Storage::Block) {
73
71
Block *Old = PointeeStorage.BS .Pointee ;
74
- if (WasBlockPointer && PointeeStorage. BS . Pointee )
72
+ if (WasBlockPointer && Old) {
75
73
PointeeStorage.BS .Pointee ->removePointer (this );
74
+ Old->cleanup ();
75
+ }
76
+ }
76
77
77
- Offset = P.Offset ;
78
+ StorageKind = P.StorageKind ;
79
+ Offset = P.Offset ;
80
+
81
+ if (P.isBlockPointer ()) {
78
82
PointeeStorage.BS = P.PointeeStorage .BS ;
79
83
80
84
if (PointeeStorage.BS .Pointee )
81
85
PointeeStorage.BS .Pointee ->addPointer (this );
82
-
83
- if (WasBlockPointer && Old)
84
- Old->cleanup ();
85
-
86
- } else if (StorageKind == Storage::Int) {
86
+ } else if (P.isIntegralPointer ()) {
87
87
PointeeStorage.Int = P.PointeeStorage .Int ;
88
88
} else {
89
89
assert (false && " Unhandled storage kind" );
90
90
}
91
91
}
92
92
93
93
void Pointer::operator =(Pointer &&P) {
94
- if (!this ->isIntegralPointer () || !P.isBlockPointer ())
95
- assert (P.StorageKind == StorageKind || (this ->isZero () && P.isZero ()));
96
-
94
+ // If the current storage type is Block, we need to remove
95
+ // this pointer from the block.
97
96
bool WasBlockPointer = isBlockPointer ();
98
- StorageKind = P.StorageKind ;
99
97
if (StorageKind == Storage::Block) {
100
98
Block *Old = PointeeStorage.BS .Pointee ;
101
- if (WasBlockPointer && PointeeStorage. BS . Pointee )
99
+ if (WasBlockPointer && Old) {
102
100
PointeeStorage.BS .Pointee ->removePointer (this );
101
+ Old->cleanup ();
102
+ }
103
+ }
103
104
104
- Offset = P.Offset ;
105
+ StorageKind = P.StorageKind ;
106
+ Offset = P.Offset ;
107
+
108
+ if (P.isBlockPointer ()) {
105
109
PointeeStorage.BS = P.PointeeStorage .BS ;
106
110
107
111
if (PointeeStorage.BS .Pointee )
108
112
PointeeStorage.BS .Pointee ->addPointer (this );
109
-
110
- if (WasBlockPointer && Old)
111
- Old->cleanup ();
112
-
113
- } else if (StorageKind == Storage::Int) {
113
+ } else if (P.isIntegralPointer ()) {
114
114
PointeeStorage.Int = P.PointeeStorage .Int ;
115
115
} else {
116
116
assert (false && " Unhandled storage kind" );
0 commit comments