[llvm] [llvm] Replace deprecated aligned_storage with aligned byte array (PR #94169)
Marc Auberer via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 2 12:51:04 PDT 2024
https://github.com/marcauberer created https://github.com/llvm/llvm-project/pull/94169
`std::aligned_storage` is deprecated with C++23, see [here](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2021/p1413r3.pdf).
This replaces the usages of `std::aligned_storage` within llvm (only one in ADT and one in Support) with an aligned `std::byte` array.
I will provide patches for other subcomponents as well.
>From 0cb76e8abd2dfad0fbe46af59eb4513b847e2d48 Mon Sep 17 00:00:00 2001
From: Marc Auberer <marc.auberer at chillibits.com>
Date: Sun, 2 Jun 2024 21:18:55 +0200
Subject: [PATCH 1/2] Replace deprecated aligned_storage with aligned byte
array
---
llvm/include/llvm/ADT/FunctionExtras.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/llvm/include/llvm/ADT/FunctionExtras.h b/llvm/include/llvm/ADT/FunctionExtras.h
index c0bc30c7450fe..49e0e8ab0db40 100644
--- a/llvm/include/llvm/ADT/FunctionExtras.h
+++ b/llvm/include/llvm/ADT/FunctionExtras.h
@@ -161,8 +161,7 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
// 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 std::byte InlineStorage[InlineStorageSize];
} StorageUnion;
// A compressed pointer to either our dispatching callback or our table of
>From edee0957ffd4fa1829e9ef2e4dd0231c0540f792 Mon Sep 17 00:00:00 2001
From: Marc Auberer <marc.auberer at chillibits.com>
Date: Sun, 2 Jun 2024 21:47:11 +0200
Subject: [PATCH 2/2] Also replace occurrences in PrettyStackTrace
---
llvm/lib/Support/PrettyStackTrace.cpp | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/llvm/lib/Support/PrettyStackTrace.cpp b/llvm/lib/Support/PrettyStackTrace.cpp
index f9f1b8a419b82..7c6d84d3697db 100644
--- a/llvm/lib/Support/PrettyStackTrace.cpp
+++ b/llvm/lib/Support/PrettyStackTrace.cpp
@@ -143,10 +143,8 @@ static void setCrashLogMessage(const char *msg) {
#ifdef __APPLE__
using CrashHandlerString = SmallString<2048>;
-using CrashHandlerStringStorage =
- std::aligned_storage<sizeof(CrashHandlerString),
- alignof(CrashHandlerString)>::type;
-static CrashHandlerStringStorage crashHandlerStringStorage;
+using CrashHandlerStringStorage = std::byte[sizeof(CrashHandlerString)];
+alignas(CrashHandlerString) static CrashHandlerStringStorage crashHandlerStringStorage;
#endif
/// This callback is run if a fatal signal is delivered to the process, it
More information about the llvm-commits
mailing list