[llvm] [llvm] Replace deprecated aligned_storage with aligned byte array (PR #94169)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 2 12:51:33 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-adt
Author: Marc Auberer (marcauberer)
<details>
<summary>Changes</summary>
`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.
---
Full diff: https://github.com/llvm/llvm-project/pull/94169.diff
2 Files Affected:
- (modified) llvm/include/llvm/ADT/FunctionExtras.h (+1-2)
- (modified) llvm/lib/Support/PrettyStackTrace.cpp (+2-4)
``````````diff
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
``````````
</details>
https://github.com/llvm/llvm-project/pull/94169
More information about the llvm-commits
mailing list