@@ -79,11 +79,15 @@ template <class ElemTy> class EquivalenceClasses {
79
79
// ECValue ctor - Start out with EndOfList pointing to this node, Next is
80
80
// Null, isLeader = true.
81
81
ECValue (const ElemTy &Elt)
82
- : Leader(this ), Next((ECValue*)(intptr_t )1 ), Data(Elt) {}
82
+ : Leader(this ),
83
+ Next (reinterpret_cast <ECValue *>(static_cast <intptr_t >(1 ))),
84
+ Data(Elt) {}
83
85
84
86
const ECValue *getLeader () const {
85
- if (isLeader ()) return this ;
86
- if (Leader->isLeader ()) return Leader;
87
+ if (isLeader ())
88
+ return this ;
89
+ if (Leader->isLeader ())
90
+ return Leader;
87
91
// Path compression.
88
92
return Leader = Leader->getLeader ();
89
93
}
@@ -95,12 +99,16 @@ template <class ElemTy> class EquivalenceClasses {
95
99
96
100
void setNext (const ECValue *NewNext) const {
97
101
assert (getNext () == nullptr && " Already has a next pointer!" );
98
- Next = (const ECValue*)((intptr_t )NewNext | (intptr_t )isLeader ());
102
+ Next = reinterpret_cast <const ECValue *>(
103
+ reinterpret_cast <intptr_t >(NewNext) |
104
+ static_cast <intptr_t >(isLeader ()));
99
105
}
100
106
101
107
public:
102
- ECValue (const ECValue &RHS) : Leader(this ), Next((ECValue*)(intptr_t )1 ),
103
- Data (RHS.Data) {
108
+ ECValue (const ECValue &RHS)
109
+ : Leader(this ),
110
+ Next(reinterpret_cast <ECValue *>(static_cast <intptr_t >(1 ))),
111
+ Data(RHS.Data) {
104
112
// Only support copying of singleton nodes.
105
113
assert (RHS.isLeader () && RHS.getNext () == nullptr && " Not a singleton!" );
106
114
}
@@ -109,7 +117,8 @@ template <class ElemTy> class EquivalenceClasses {
109
117
const ElemTy &getData () const { return Data; }
110
118
111
119
const ECValue *getNext () const {
112
- return (ECValue*)((intptr_t )Next & ~(intptr_t )1 );
120
+ return reinterpret_cast <ECValue *>(reinterpret_cast <intptr_t >(Next) &
121
+ ~static_cast <intptr_t >(1 ));
113
122
}
114
123
};
115
124
@@ -124,9 +133,7 @@ template <class ElemTy> class EquivalenceClasses {
124
133
125
134
public:
126
135
EquivalenceClasses () = default;
127
- EquivalenceClasses (const EquivalenceClasses &RHS) {
128
- operator =(RHS);
129
- }
136
+ EquivalenceClasses (const EquivalenceClasses &RHS) { operator =(RHS); }
130
137
131
138
EquivalenceClasses &operator =(const EquivalenceClasses &RHS) {
132
139
TheMapping.clear ();
@@ -160,9 +167,7 @@ template <class ElemTy> class EquivalenceClasses {
160
167
return member_iterator (ECV.isLeader () ? &ECV : nullptr );
161
168
}
162
169
163
- member_iterator member_end () const {
164
- return member_iterator (nullptr );
165
- }
170
+ member_iterator member_end () const { return member_iterator (nullptr ); }
166
171
167
172
iterator_range<member_iterator> members (const ECValue &ECV) const {
168
173
return make_range (member_begin (ECV), member_end ());
@@ -294,7 +299,8 @@ template <class ElemTy> class EquivalenceClasses {
294
299
}
295
300
member_iterator unionSets (member_iterator L1, member_iterator L2) {
296
301
assert (L1 != member_end () && L2 != member_end () && " Illegal inputs!" );
297
- if (L1 == L2) return L1; // Unifying the same two sets, noop.
302
+ if (L1 == L2)
303
+ return L1; // Unifying the same two sets, noop.
298
304
299
305
// Otherwise, this is a real union operation. Set the end of the L1 list to
300
306
// point to the L2 leader node.
@@ -350,7 +356,7 @@ template <class ElemTy> class EquivalenceClasses {
350
356
return *this ;
351
357
}
352
358
353
- member_iterator operator ++(int ) { // postincrement operators.
359
+ member_iterator operator ++(int ) { // postincrement operators.
354
360
member_iterator tmp = *this ;
355
361
++*this ;
356
362
return tmp;
0 commit comments