LLVM
10.0.0
include
llvm
Support
AlignOf.h
Go to the documentation of this file.
1
//===--- AlignOf.h - Portable calculation of type alignment -----*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This file defines the AlignedCharArrayUnion class.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_SUPPORT_ALIGNOF_H
14
#define LLVM_SUPPORT_ALIGNOF_H
15
16
#include "
llvm/Support/Compiler.h
"
17
#include <cstddef>
18
19
namespace
llvm
{
20
21
namespace
detail {
22
23
template
<
typename
T
,
typename
... Ts>
class
AlignerImpl
{
24
T
t;
25
AlignerImpl
<Ts...> rest;
26
AlignerImpl
() =
delete
;
27
};
28
29
template
<
typename
T>
class
AlignerImpl
<
T
> {
30
T
t;
31
AlignerImpl
() =
delete
;
32
};
33
34
template
<
typename
T
,
typename
... Ts>
union
SizerImpl
{
35
char
arr[
sizeof
(
T
)];
36
SizerImpl
<Ts...>
rest
;
37
};
38
39
template
<
typename
T>
union
SizerImpl
<
T
> {
char
arr[
sizeof
(
T
)]; };
40
}
// end namespace detail
41
42
/// A suitably aligned and sized character array member which can hold elements
43
/// of any type.
44
///
45
/// These types may be arrays, structs, or any other types. This exposes a
46
/// `buffer` member which can be used as suitable storage for a placement new of
47
/// any of these types.
48
template
<
typename
T
,
typename
... Ts>
struct
AlignedCharArrayUnion
{
49
alignas
(
::llvm::detail::AlignerImpl
<
T
, Ts...>)
char
buffer[
sizeof
(
50
llvm::detail::SizerImpl<T, Ts...>
)];
51
};
52
53
}
// end namespace llvm
54
55
#endif // LLVM_SUPPORT_ALIGNOF_H
llvm
This class represents lattice values for constants.
Definition:
AllocatorList.h:23
llvm::T
Definition:
ARMBaseInstrInfo.h:495
llvm::detail::SizerImpl::rest
SizerImpl< Ts... > rest
Definition:
AlignOf.h:36
Compiler.h
llvm::detail::SizerImpl
Definition:
AlignOf.h:34
T
llvm::AlignedCharArrayUnion
A suitably aligned and sized character array member which can hold elements of any type...
Definition:
AlignOf.h:48
llvm::detail::AlignerImpl
Definition:
AlignOf.h:23
Generated on Tue Mar 24 2020 13:08:26 for LLVM by
1.8.13