This is an archive of the discontinued LLVM Phabricator instance.

Convert PointerUnion to a variadic template.
ClosedPublic

Authored by rsmith on May 16 2019, 1:17 PM.

Details

Summary

Rather than duplicating code between PointerUnion, PointerUnion3, and
PointerUnion4 (and missing things from the latter cases, such as some of the
DenseMap support and operator==), convert PointerUnion to a variadic template
that can be used as a union of any number of pointers.

(This doesn't support PointerUnion<> right now. Adding a special case for that
would be possible, and perhaps even useful in some situations, but it doesn't
seem worthwhile until we have a concrete use case.)

Diff Detail

Event Timeline

rsmith created this revision.May 16 2019, 1:17 PM

This implementation is accepted by the lowest supported versions of all of our supported compilers: https://godbolt.org/z/yZJDu3

dblaikie accepted this revision.May 16 2019, 3:41 PM

Nice!

This revision is now accepted and ready to land.May 16 2019, 3:41 PM
This revision was automatically updated to reflect the committed changes.