Skip to content

Commit bf4eaec

Browse files
authored
[llvm] Replace deprecated aligned_storage with aligned byte array (#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.
1 parent 4f2dba3 commit bf4eaec

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

llvm/include/llvm/ADT/FunctionExtras.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,7 @@ template <typename ReturnT, typename... ParamTs> class UniqueFunctionBase {
161161
// provide three pointers worth of storage here.
162162
// This is mutable as an inlined `const unique_function<void() const>` may
163163
// still modify its own mutable members.
164-
mutable std::aligned_storage_t<InlineStorageSize, alignof(void *)>
165-
InlineStorage;
164+
alignas(void *) mutable std::byte InlineStorage[InlineStorageSize];
166165
} StorageUnion;
167166

168167
// A compressed pointer to either our dispatching callback or our table of

llvm/lib/Support/PrettyStackTrace.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,9 @@ static void setCrashLogMessage(const char *msg) {
143143

144144
#ifdef __APPLE__
145145
using CrashHandlerString = SmallString<2048>;
146-
using CrashHandlerStringStorage =
147-
std::aligned_storage<sizeof(CrashHandlerString),
148-
alignof(CrashHandlerString)>::type;
149-
static CrashHandlerStringStorage crashHandlerStringStorage;
146+
using CrashHandlerStringStorage = std::byte[sizeof(CrashHandlerString)];
147+
alignas(CrashHandlerString) static CrashHandlerStringStorage
148+
crashHandlerStringStorage;
150149
#endif
151150

152151
/// This callback is run if a fatal signal is delivered to the process, it

0 commit comments

Comments
 (0)