[llvm] 90a202f - [cpp23] Remove usage of std::aligned_union<> in llvm (#135146)

via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 11 13:16:38 PDT 2025


Author: Victor Vianna
Date: 2025-04-11T16:16:33-04:00
New Revision: 90a202f2ff241a9f4b11ec625dcc3446cbceb924

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

LOG: [cpp23] Remove usage of std::aligned_union<> in llvm (#135146)

std::aligned_union<> is deprecated in C++23. See more details in the
linked bug.

Bug: https://crbug.com/388068052

Added: 
    

Modified: 
    compiler-rt/lib/orc/error.h
    llvm/include/llvm/ADT/TrieRawHashMap.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/orc/error.h b/compiler-rt/lib/orc/error.h
index e64332e9ae764..28035095b692a 100644
--- a/compiler-rt/lib/orc/error.h
+++ b/compiler-rt/lib/orc/error.h
@@ -367,8 +367,8 @@ template <typename T> class ORC_RT_NODISCARD Expected {
   }
 
   union {
-    std::aligned_union_t<1, storage_type> TStorage;
-    std::aligned_union_t<1, error_type> ErrorStorage;
+    alignas(storage_type) char TStorage[sizeof(storage_type)];
+    alignas(error_type) char ErrorStorage[sizeof(error_type)];
   };
 
   bool HasError : 1;

diff  --git a/llvm/include/llvm/ADT/TrieRawHashMap.h b/llvm/include/llvm/ADT/TrieRawHashMap.h
index 5bfe5c9e6a0f4..e312967edeb58 100644
--- a/llvm/include/llvm/ADT/TrieRawHashMap.h
+++ b/llvm/include/llvm/ADT/TrieRawHashMap.h
@@ -72,7 +72,7 @@ class ThreadSafeTrieRawHashMapBase {
 private:
   template <class T> struct AllocValueType {
     char Base[TrieContentBaseSize];
-    std::aligned_union_t<sizeof(T), T> Content;
+    alignas(T) char Content[sizeof(T)];
   };
 
 protected:


        


More information about the llvm-commits mailing list