diff options
author | Reid Kleckner <rnk@google.com> | 2020-12-15 15:59:21 -0800 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2020-12-15 16:01:55 -0800 |
commit | b0b5d389635a54c5aeb490b1b067f3a38e038235 (patch) | |
tree | 3b59fe93c36dac61c588af198b802fb9f890aac5 | |
parent | f43e67cc6c6f6e0da925039b28b54e44fc751267 (diff) | |
download | llvm-b0b5d389635a54c5aeb490b1b067f3a38e038235.zip llvm-b0b5d389635a54c5aeb490b1b067f3a38e038235.tar.gz llvm-b0b5d389635a54c5aeb490b1b067f3a38e038235.tar.bz2 |
Document that AlignedCharArrayUnion exists to work around an MSVC bug
Differential Revision: https://reviews.llvm.org/D93355
-rw-r--r-- | llvm/include/llvm/Support/AlignOf.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/include/llvm/Support/AlignOf.h b/llvm/include/llvm/Support/AlignOf.h index f9dcde4..f586d7f 100644 --- a/llvm/include/llvm/Support/AlignOf.h +++ b/llvm/include/llvm/Support/AlignOf.h @@ -20,9 +20,10 @@ 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. +/// This template is equivalent to std::aligned_union_t<1, ...>, but we cannot +/// use it due to a bug in the MSVC x86 compiler: +/// https://github.com/microsoft/STL/issues/1533 +/// Using `alignas` here works around the bug. template <typename T, typename... Ts> struct AlignedCharArrayUnion { using AlignedUnion = std::aligned_union_t<1, T, Ts...>; alignas(alignof(AlignedUnion)) char buffer[sizeof(AlignedUnion)]; |