Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:27

0001 //===--- AlignOf.h - Portable calculation of type alignment -----*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file defines the AlignedCharArrayUnion class.
0010 //
0011 //===----------------------------------------------------------------------===//
0012 
0013 #ifndef LLVM_SUPPORT_ALIGNOF_H
0014 #define LLVM_SUPPORT_ALIGNOF_H
0015 
0016 #include <type_traits>
0017 
0018 namespace llvm {
0019 
0020 /// A suitably aligned and sized character array member which can hold elements
0021 /// of any type.
0022 ///
0023 /// This template is equivalent to std::aligned_union_t<1, ...>, but we cannot
0024 /// use it due to a bug in the MSVC x86 compiler:
0025 /// https://github.com/microsoft/STL/issues/1533
0026 /// Using `alignas` here works around the bug.
0027 template <typename T, typename... Ts> struct AlignedCharArrayUnion {
0028   using AlignedUnion = std::aligned_union_t<1, T, Ts...>;
0029   alignas(alignof(AlignedUnion)) char buffer[sizeof(AlignedUnion)];
0030 };
0031 
0032 } // end namespace llvm
0033 
0034 #endif // LLVM_SUPPORT_ALIGNOF_H