[PATCH] D92500: ADT: Replace guts of AlignedCharArrayUnion with std::aligned_union_t, NFC
Duncan P. N. Exon Smith via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 2 15:56:29 PST 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG65c5c9f92ec5: ADT: Rely on std::aligned_union_t for math in AlignedCharArrayUnion, NFC (authored by dexonsmith).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92500/new/
https://reviews.llvm.org/D92500
Files:
llvm/include/llvm/Support/AlignOf.h
Index: llvm/include/llvm/Support/AlignOf.h
===================================================================
--- llvm/include/llvm/Support/AlignOf.h
+++ llvm/include/llvm/Support/AlignOf.h
@@ -13,32 +13,10 @@
#ifndef LLVM_SUPPORT_ALIGNOF_H
#define LLVM_SUPPORT_ALIGNOF_H
-#include "llvm/Support/Compiler.h"
-#include <cstddef>
+#include <type_traits>
namespace llvm {
-namespace detail {
-
-template <typename T, typename... Ts> class AlignerImpl {
- T t;
- AlignerImpl<Ts...> rest;
- AlignerImpl() = delete;
-};
-
-template <typename T> class AlignerImpl<T> {
- T t;
- AlignerImpl() = delete;
-};
-
-template <typename T, typename... Ts> union SizerImpl {
- char arr[sizeof(T)];
- SizerImpl<Ts...> rest;
-};
-
-template <typename T> union SizerImpl<T> { char arr[sizeof(T)]; };
-} // end namespace detail
-
/// A suitably aligned and sized character array member which can hold elements
/// of any type.
///
@@ -46,8 +24,8 @@
/// `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 {
- alignas(::llvm::detail::AlignerImpl<T, Ts...>) char buffer[sizeof(
- llvm::detail::SizerImpl<T, Ts...>)];
+ using AlignedUnion = std::aligned_union_t<1, T, Ts...>;
+ alignas(alignof(AlignedUnion)) char buffer[sizeof(AlignedUnion)];
};
} // end namespace llvm
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92500.309086.patch
Type: text/x-patch
Size: 1398 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201202/e9d44363/attachment.bin>
More information about the llvm-commits
mailing list