HomePhabricator

ADT: Rely on std::aligned_union_t for math in AlignedCharArrayUnion, NFC

Authored by dexonsmith on Dec 2 2020, 11:43 AM.

Description

ADT: Rely on std::aligned_union_t for math in AlignedCharArrayUnion, NFC

Instead of computing the alignment and size of the char buffer in
AlignedCharArrayUnion, rely on the math in std::aligned_union_t.
Because some users of this rely on the buffer field existing with a
type convertible to char *, we can't change the field type, but we can
still avoid duplicating the logic.

A potential follow up would be to delete AlignedCharArrayUnion after
updating its users to use std::aligned_union_t directly; or if we like
our template parameters better, could update users to stop peeking
inside and then replace the definition with:

template <class T, class... Ts>
using AlignedCharArrayUnion = std::aligned_union_t<1, T, Ts...>;

Differential Revision: https://reviews.llvm.org/D92500