[llvm] bf4eaec - [llvm] Replace deprecated aligned_storage with aligned byte array (#94169)

via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 3 02:55:41 PDT 2024


Author: Marc Auberer
Date: 2024-06-03T11:55:37+02:00
New Revision: bf4eaec44054fa3908d50898f572e15d89119c67

URL: https://github.com/llvm/llvm-project/commit/bf4eaec44054fa3908d50898f572e15d89119c67
DIFF: https://github.com/llvm/llvm-project/commit/bf4eaec44054fa3908d50898f572e15d89119c67.diff

LOG: [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.

Added: 
    

Modified: 
    llvm/include/llvm/ADT/FunctionExtras.h
    llvm/lib/Support/PrettyStackTrace.cpp

Removed: 
    


################################################################################
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..9b09384e95bfe 100644
--- a/llvm/lib/Support/PrettyStackTrace.cpp
+++ b/llvm/lib/Support/PrettyStackTrace.cpp
@@ -143,10 +143,9 @@ 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