-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[llvm] Replace deprecated aligned_storage with aligned byte array #94169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[llvm] Replace deprecated aligned_storage with aligned byte array #94169
Conversation
@llvm/pr-subscribers-llvm-adt Author: Marc Auberer (marcauberer) Changes
This replaces the usages of Full diff: https://github.com/llvm/llvm-project/pull/94169.diff 2 Files Affected:
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
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
|
@llvm/pr-subscribers-llvm-support Author: Marc Auberer (marcauberer) Changes
This replaces the usages of Full diff: https://github.com/llvm/llvm-project/pull/94169.diff 2 Files Affected:
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
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
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
Why? We are not even close to C++20? |
As these are in headers, which are transitively included by users (which potentially use C++23). So they will get the deprecation warnings as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SGTM
std::aligned_storage
is deprecated with C++23, see here.This replaces the usages of
std::aligned_storage
within llvm (only one in ADT and one in Support) with an alignedstd::byte
array.I will provide patches for other subcomponents as well.