[cpp23] Remove usage of std::aligned_storage/union<> in swiftshader Deprecated in C++23. Bug: chromium:388068052 Change-Id: I118cd9c9064c48905d1f565d635549670eac1969 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/74809 Tested-by: Shahbaz Youssefi <syoussefi@google.com> Commit-Queue: Shahbaz Youssefi <syoussefi@google.com> Reviewed-by: Shahbaz Youssefi <syoussefi@google.com>
diff --git a/third_party/llvm-10.0/llvm/include/llvm/ADT/FunctionExtras.h b/third_party/llvm-10.0/llvm/include/llvm/ADT/FunctionExtras.h index 121aa52..daa74b2 100644 --- a/third_party/llvm-10.0/llvm/include/llvm/ADT/FunctionExtras.h +++ b/third_party/llvm-10.0/llvm/include/llvm/ADT/FunctionExtras.h
@@ -112,8 +112,7 @@ // For in-line storage, we just provide an aligned character buffer. We // provide three pointers worth of storage here. - typename std::aligned_storage<InlineStorageSize, alignof(void *)>::type - InlineStorage; + alignas(void *) char InlineStorage[InlineStorageSize]; } StorageUnion; // A compressed pointer to either our dispatching callback or our table of
diff --git a/third_party/llvm-10.0/llvm/lib/Support/PrettyStackTrace.cpp b/third_party/llvm-10.0/llvm/lib/Support/PrettyStackTrace.cpp index 5531ad6..c03171d 100644 --- a/third_party/llvm-10.0/llvm/lib/Support/PrettyStackTrace.cpp +++ b/third_party/llvm-10.0/llvm/lib/Support/PrettyStackTrace.cpp
@@ -134,10 +134,7 @@ #ifdef __APPLE__ using CrashHandlerString = SmallString<2048>; -using CrashHandlerStringStorage = - std::aligned_storage<sizeof(CrashHandlerString), - alignof(CrashHandlerString)>::type; -static CrashHandlerStringStorage crashHandlerStringStorage; +static alignas(CrashHandlerString) char crashHandlerStringStorage[sizeof(CrashHandlerString)]; #endif /// This callback is run if a fatal signal is delivered to the process, it
diff --git a/third_party/llvm-10.0/llvm/lib/XRay/Trace.cpp b/third_party/llvm-10.0/llvm/lib/XRay/Trace.cpp index 4f107e1..df95a53 100644 --- a/third_party/llvm-10.0/llvm/lib/XRay/Trace.cpp +++ b/third_party/llvm-10.0/llvm/lib/XRay/Trace.cpp
@@ -30,9 +30,6 @@ using llvm::yaml::Input; namespace { -using XRayRecordStorage = - std::aligned_storage<sizeof(XRayRecord), alignof(XRayRecord)>::type; - Error loadNaiveFormatLog(StringRef Data, bool IsLittleEndian, XRayFileHeader &FileHeader, std::vector<XRayRecord> &Records) {
diff --git a/third_party/llvm-16.0/llvm/include/llvm/ADT/FunctionExtras.h b/third_party/llvm-16.0/llvm/include/llvm/ADT/FunctionExtras.h index 8f04277..f3c5136 100644 --- a/third_party/llvm-16.0/llvm/include/llvm/ADT/FunctionExtras.h +++ b/third_party/llvm-16.0/llvm/include/llvm/ADT/FunctionExtras.h
@@ -160,8 +160,7 @@ // provide three pointers worth of storage here. // This is mutable as an inlined `const unique_function<void() const>` may // still modify its own mutable members. - mutable std::aligned_storage_t<InlineStorageSize, alignof(void *)> - InlineStorage; + alignas(void *) mutable char InlineStorage[InlineStorageSize]; } StorageUnion; // A compressed pointer to either our dispatching callback or our table of
diff --git a/third_party/llvm-16.0/llvm/include/llvm/Support/AlignOf.h b/third_party/llvm-16.0/llvm/include/llvm/Support/AlignOf.h index f586d7f..a8c4578 100644 --- a/third_party/llvm-16.0/llvm/include/llvm/Support/AlignOf.h +++ b/third_party/llvm-16.0/llvm/include/llvm/Support/AlignOf.h
@@ -13,20 +13,14 @@ #ifndef LLVM_SUPPORT_ALIGNOF_H #define LLVM_SUPPORT_ALIGNOF_H -#include <type_traits> +#include <algorithm> namespace llvm { /// A suitably aligned and sized character array member which can hold elements /// of any type. -/// -/// 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)]; + alignas(Ts...) char buffer[std::max({sizeof(Ts)...})]; }; } // end namespace llvm
diff --git a/third_party/llvm-16.0/llvm/lib/Support/PrettyStackTrace.cpp b/third_party/llvm-16.0/llvm/lib/Support/PrettyStackTrace.cpp index fa91405..b5271e8 100644 --- a/third_party/llvm-16.0/llvm/lib/Support/PrettyStackTrace.cpp +++ b/third_party/llvm-16.0/llvm/lib/Support/PrettyStackTrace.cpp
@@ -144,10 +144,7 @@ #ifdef __APPLE__ using CrashHandlerString = SmallString<2048>; -using CrashHandlerStringStorage = - std::aligned_storage<sizeof(CrashHandlerString), - alignof(CrashHandlerString)>::type; -static CrashHandlerStringStorage crashHandlerStringStorage; +static alignas(CrashHandlerString) char crashHandlerStringStorage[sizeof(CrashHandlerString)]; #endif /// This callback is run if a fatal signal is delivered to the process, it