ADT: Change AlignedCharArrayUnion to an alias of std::aligned_union_t, NFC
authorDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 4 Dec 2020 02:37:59 +0000 (18:37 -0800)
committerDuncan P. N. Exon Smith <dexonsmith@apple.com>
Fri, 4 Dec 2020 19:59:35 +0000 (11:59 -0800)
All the users of `AlignedCharArrayUnion` were changed in
5b267fb7966157e0d79ea85cbc1d07f92f840d3c to stop peeking inside (to look
at `buffer`), so this finishes gutting it. It's now an alias of
`std::aligned_union_t`, with a minor difference in template parameters
(`std::aligned_union_t` takes a minimum size and 0+ types, whereas this
just takes 1+ types... maybe a bit simpler to use correctly?).

A follow up will remove `AlignedCharArrayUnion` entirely, inlining this
alias into its users.

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

llvm/include/llvm/Support/AlignOf.h

index f9dcde4..2b293ca 100644 (file)
@@ -20,13 +20,11 @@ namespace llvm {
 /// A suitably aligned and sized character array member which can hold elements
 /// of any type.
 ///
-/// These types may be arrays, structs, or any other types. This exposes a
-/// `buffer` member which can be used as suitable storage for a placement new of
-/// any of these types.
-template <typename T, typename... Ts> struct AlignedCharArrayUnion {
-  using AlignedUnion = std::aligned_union_t<1, T, Ts...>;
-  alignas(alignof(AlignedUnion)) char buffer[sizeof(AlignedUnion)];
-};
+/// These types may be arrays, structs, or any other types. Underneath is a
+/// char buffer member which can be used as suitable storage for a placement
+/// new of any of these types.
+template <typename T, typename... Ts>
+using AlignedCharArrayUnion = std::aligned_union_t<1, T, Ts...>;
 
 } // end namespace llvm