[llvm] [ADT] Specialize ValueIsPresent for PointerUnion (PR #121847)
Jakub Kuderski via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 8 07:48:09 PST 2025
================
@@ -259,6 +259,17 @@ struct CastInfo<To, const PointerUnion<PTs...>>
CastInfo<To, PointerUnion<PTs...>>> {
};
+// The default implementation of isPresent() for nullable types returns true
+// if the active member is not the first one, even if its value is nullptr.
+// Override the default behavior to return false for all possible null values.
+template <typename... PTs>
+struct ValueIsPresent<PointerUnion<PTs...>,
+ std::enable_if_t<IsNullable<PointerUnion<PTs...>>>> {
----------------
kuhar wrote:
I think the underlying issue is that without this, the main partial specialization from here would be as good of a match as this one: https://github.com/llvm/llvm-project/blob/2a4992e9e34de6b74aa8c254fea867d1271b3e97/llvm/include/llvm/Support/Casting.h#L622 . IE I don't think the exact predicate used in this enable_if matters as long as it evaluates to `void` at the end both L622 and here. In the godbolt link, `enable_if<true>` doesn't work because it appears in non-deduced context.
https://github.com/llvm/llvm-project/pull/121847
More information about the llvm-commits
mailing list