@@ -198,14 +198,14 @@ class PointerUnion
198
198
}
199
199
};
200
200
201
- template <typename ... PTs>
202
- bool operator ==(PointerUnion<PTs...> LHS , PointerUnion<PTs...> RHS ) {
203
- return (!LHS && !RHS) || LHS .getOpaqueValue () == RHS .getOpaqueValue ();
201
+ template <typename ...PTs>
202
+ bool operator ==(PointerUnion<PTs...> lhs , PointerUnion<PTs...> rhs ) {
203
+ return lhs .getOpaqueValue () == rhs .getOpaqueValue ();
204
204
}
205
205
206
- template <typename ... PTs>
207
- bool operator !=(PointerUnion<PTs...> LHS , PointerUnion<PTs...> RHS ) {
208
- return ! operator ==(LHS, RHS );
206
+ template <typename ...PTs>
207
+ bool operator !=(PointerUnion<PTs...> lhs , PointerUnion<PTs...> rhs ) {
208
+ return lhs. getOpaqueValue () != rhs. getOpaqueValue ( );
209
209
}
210
210
211
211
template <typename ...PTs>
@@ -259,6 +259,17 @@ struct CastInfo<To, const PointerUnion<PTs...>>
259
259
CastInfo<To, PointerUnion<PTs...>>> {
260
260
};
261
261
262
+ // The default implementation of isPresent() for nullable types returns true
263
+ // if the active member is not the first one, even if its value is nullptr.
264
+ // Override the default behavior to return false for all possible null values.
265
+ template <typename ... PTs>
266
+ struct ValueIsPresent <PointerUnion<PTs...>,
267
+ std::enable_if_t <IsNullable<PointerUnion<PTs...>>>> {
268
+ using Union = PointerUnion<PTs...>;
269
+ static bool isPresent (const Union &V) { return static_cast <bool >(V); }
270
+ static decltype (auto ) unwrapValue(Union &V) { return V; }
271
+ };
272
+
262
273
// Teach SmallPtrSet that PointerUnion is "basically a pointer", that has
263
274
// # low bits available = min(PT1bits,PT2bits)-1.
264
275
template <typename ...PTs>
0 commit comments