/home/arjun/llvm-project/llvm/include/llvm/Support/TrailingObjects.h
Line | Count | Source (jump to first uncovered line) |
1 | | //===--- TrailingObjects.h - Variable-length classes ------------*- 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 | | /// \file |
10 | | /// This header defines support for implementing classes that have |
11 | | /// some trailing object (or arrays of objects) appended to them. The |
12 | | /// main purpose is to make it obvious where this idiom is being used, |
13 | | /// and to make the usage more idiomatic and more difficult to get |
14 | | /// wrong. |
15 | | /// |
16 | | /// The TrailingObject template abstracts away the reinterpret_cast, |
17 | | /// pointer arithmetic, and size calculations used for the allocation |
18 | | /// and access of appended arrays of objects, and takes care that they |
19 | | /// are all allocated at their required alignment. Additionally, it |
20 | | /// ensures that the base type is final -- deriving from a class that |
21 | | /// expects data appended immediately after it is typically not safe. |
22 | | /// |
23 | | /// Users are expected to derive from this template, and provide |
24 | | /// numTrailingObjects implementations for each trailing type except |
25 | | /// the last, e.g. like this sample: |
26 | | /// |
27 | | /// \code |
28 | | /// class VarLengthObj : private TrailingObjects<VarLengthObj, int, double> { |
29 | | /// friend TrailingObjects; |
30 | | /// |
31 | | /// unsigned NumInts, NumDoubles; |
32 | | /// size_t numTrailingObjects(OverloadToken<int>) const { return NumInts; } |
33 | | /// }; |
34 | | /// \endcode |
35 | | /// |
36 | | /// You can access the appended arrays via 'getTrailingObjects', and |
37 | | /// determine the size needed for allocation via |
38 | | /// 'additionalSizeToAlloc' and 'totalSizeToAlloc'. |
39 | | /// |
40 | | /// All the methods implemented by this class are are intended for use |
41 | | /// by the implementation of the class, not as part of its interface |
42 | | /// (thus, private inheritance is suggested). |
43 | | /// |
44 | | //===----------------------------------------------------------------------===// |
45 | | |
46 | | #ifndef LLVM_SUPPORT_TRAILINGOBJECTS_H |
47 | | #define LLVM_SUPPORT_TRAILINGOBJECTS_H |
48 | | |
49 | | #include "llvm/Support/AlignOf.h" |
50 | | #include "llvm/Support/Alignment.h" |
51 | | #include "llvm/Support/Compiler.h" |
52 | | #include "llvm/Support/MathExtras.h" |
53 | | #include "llvm/Support/type_traits.h" |
54 | | #include <new> |
55 | | #include <type_traits> |
56 | | |
57 | | namespace llvm { |
58 | | |
59 | | namespace trailing_objects_internal { |
60 | | /// Helper template to calculate the max alignment requirement for a set of |
61 | | /// objects. |
62 | | template <typename First, typename... Rest> class AlignmentCalcHelper { |
63 | | private: |
64 | | enum { |
65 | | FirstAlignment = alignof(First), |
66 | | RestAlignment = AlignmentCalcHelper<Rest...>::Alignment, |
67 | | }; |
68 | | |
69 | | public: |
70 | | enum { |
71 | | Alignment = FirstAlignment > RestAlignment ? FirstAlignment : RestAlignment |
72 | | }; |
73 | | }; |
74 | | |
75 | | template <typename First> class AlignmentCalcHelper<First> { |
76 | | public: |
77 | | enum { Alignment = alignof(First) }; |
78 | | }; |
79 | | |
80 | | /// The base class for TrailingObjects* classes. |
81 | | class TrailingObjectsBase { |
82 | | protected: |
83 | | /// OverloadToken's purpose is to allow specifying function overloads |
84 | | /// for different types, without actually taking the types as |
85 | | /// parameters. (Necessary because member function templates cannot |
86 | | /// be specialized, so overloads must be used instead of |
87 | | /// specialization.) |
88 | | template <typename T> struct OverloadToken {}; |
89 | | }; |
90 | | |
91 | | template <int Align> |
92 | | class TrailingObjectsAligner : public TrailingObjectsBase {}; |
93 | | template <> |
94 | | class alignas(1) TrailingObjectsAligner<1> : public TrailingObjectsBase {}; |
95 | | template <> |
96 | | class alignas(2) TrailingObjectsAligner<2> : public TrailingObjectsBase {}; |
97 | | template <> |
98 | | class alignas(4) TrailingObjectsAligner<4> : public TrailingObjectsBase {}; |
99 | | template <> |
100 | | class alignas(8) TrailingObjectsAligner<8> : public TrailingObjectsBase {}; |
101 | | template <> |
102 | | class alignas(16) TrailingObjectsAligner<16> : public TrailingObjectsBase { |
103 | | }; |
104 | | template <> |
105 | | class alignas(32) TrailingObjectsAligner<32> : public TrailingObjectsBase { |
106 | | }; |
107 | | |
108 | | // Just a little helper for transforming a type pack into the same |
109 | | // number of a different type. e.g.: |
110 | | // ExtractSecondType<Foo..., int>::type |
111 | | template <typename Ty1, typename Ty2> struct ExtractSecondType { |
112 | | typedef Ty2 type; |
113 | | }; |
114 | | |
115 | | // TrailingObjectsImpl is somewhat complicated, because it is a |
116 | | // recursively inheriting template, in order to handle the template |
117 | | // varargs. Each level of inheritance picks off a single trailing type |
118 | | // then recurses on the rest. The "Align", "BaseTy", and |
119 | | // "TopTrailingObj" arguments are passed through unchanged through the |
120 | | // recursion. "PrevTy" is, at each level, the type handled by the |
121 | | // level right above it. |
122 | | |
123 | | template <int Align, typename BaseTy, typename TopTrailingObj, typename PrevTy, |
124 | | typename... MoreTys> |
125 | | class TrailingObjectsImpl { |
126 | | // The main template definition is never used -- the two |
127 | | // specializations cover all possibilities. |
128 | | }; |
129 | | |
130 | | template <int Align, typename BaseTy, typename TopTrailingObj, typename PrevTy, |
131 | | typename NextTy, typename... MoreTys> |
132 | | class TrailingObjectsImpl<Align, BaseTy, TopTrailingObj, PrevTy, NextTy, |
133 | | MoreTys...> |
134 | | : public TrailingObjectsImpl<Align, BaseTy, TopTrailingObj, NextTy, |
135 | | MoreTys...> { |
136 | | |
137 | | typedef TrailingObjectsImpl<Align, BaseTy, TopTrailingObj, NextTy, MoreTys...> |
138 | | ParentType; |
139 | | |
140 | | struct RequiresRealignment { |
141 | | static const bool value = alignof(PrevTy) < alignof(NextTy); |
142 | | }; |
143 | | |
144 | 0 | static constexpr bool requiresRealignment() { |
145 | 0 | return RequiresRealignment::value; |
146 | 0 | } Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail14OperandStorageENS_15TrailingObjectsIS4_JNS2_9OpOperandEEEES4_JS6_EE19requiresRealignmentEv Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail22TrailingOperandStorageENS_15TrailingObjectsIS4_JNS2_9OpOperandEEEES4_JS6_EE19requiresRealignmentEv Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir9OperationENS_15TrailingObjectsIS3_JNS2_6detail14InLineOpResultENS5_16TrailingOpResultENS2_12BlockOperandENS2_6RegionENS5_14OperandStorageEEEES8_JS9_SA_EE19requiresRealignmentEv Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir9OperationENS_15TrailingObjectsIS3_JNS2_6detail14InLineOpResultENS5_16TrailingOpResultENS2_12BlockOperandENS2_6RegionENS5_14OperandStorageEEEES7_JS8_S9_SA_EE19requiresRealignmentEv Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir9OperationENS_15TrailingObjectsIS3_JNS2_6detail14InLineOpResultENS5_16TrailingOpResultENS2_12BlockOperandENS2_6RegionENS5_14OperandStorageEEEES6_JS7_S8_S9_SA_EE19requiresRealignmentEv Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir9OperationENS_15TrailingObjectsIS3_JNS2_6detail14InLineOpResultENS5_16TrailingOpResultENS2_12BlockOperandENS2_6RegionENS5_14OperandStorageEEEES3_JS6_S7_S8_S9_SA_EE19requiresRealignmentEv Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir9OperationENS_15TrailingObjectsIS3_JNS2_6detail14InLineOpResultENS5_16TrailingOpResultENS2_12BlockOperandENS2_6RegionENS5_14OperandStorageEEEES9_JSA_EE19requiresRealignmentEv Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail26DictionaryAttributeStorageENS_15TrailingObjectsIS4_JSt4pairINS2_10IdentifierENS2_9AttributeEEEEES4_JS9_EE19requiresRealignmentEv Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail21FloatAttributeStorageENS_15TrailingObjectsIS4_JmEEES4_JmEE19requiresRealignmentEv Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail23IntegerAttributeStorageENS_15TrailingObjectsIS4_JmEEES4_JmEE19requiresRealignmentEv Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail25SymbolRefAttributeStorageENS_15TrailingObjectsIS4_JNS2_17FlatSymbolRefAttrEEEES4_JS6_EE19requiresRealignmentEv Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail20FusedLocationStorageENS_15TrailingObjectsIS4_JNS2_8LocationEEEES4_JS6_EE19requiresRealignmentEv Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail16TupleTypeStorageENS_15TrailingObjectsIS4_JNS2_4TypeEEEES4_JS6_EE19requiresRealignmentEv |
147 | | |
148 | | protected: |
149 | | // Ensure the inherited getTrailingObjectsImpl is not hidden. |
150 | | using ParentType::getTrailingObjectsImpl; |
151 | | |
152 | | // These two functions are helper functions for |
153 | | // TrailingObjects::getTrailingObjects. They recurse to the left -- |
154 | | // the result for each type in the list of trailing types depends on |
155 | | // the result of calling the function on the type to the |
156 | | // left. However, the function for the type to the left is |
157 | | // implemented by a *subclass* of this class, so we invoke it via |
158 | | // the TopTrailingObj, which is, via the |
159 | | // curiously-recurring-template-pattern, the most-derived type in |
160 | | // this recursion, and thus, contains all the overloads. |
161 | | static const NextTy * |
162 | | getTrailingObjectsImpl(const BaseTy *Obj, |
163 | 0 | TrailingObjectsBase::OverloadToken<NextTy>) { |
164 | 0 | auto *Ptr = TopTrailingObj::getTrailingObjectsImpl( |
165 | 0 | Obj, TrailingObjectsBase::OverloadToken<PrevTy>()) + |
166 | 0 | TopTrailingObj::callNumTrailingObjects( |
167 | 0 | Obj, TrailingObjectsBase::OverloadToken<PrevTy>()); |
168 | 0 |
|
169 | 0 | if (requiresRealignment()) |
170 | 0 | return reinterpret_cast<const NextTy *>( |
171 | 0 | alignAddr(Ptr, Align::Of<NextTy>())); |
172 | 0 | else |
173 | 0 | return reinterpret_cast<const NextTy *>(Ptr); |
174 | 0 | } Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail26DictionaryAttributeStorageENS_15TrailingObjectsIS4_JSt4pairINS2_10IdentifierENS2_9AttributeEEEEES4_JS9_EE22getTrailingObjectsImplEPKS4_NS0_19TrailingObjectsBase13OverloadTokenIS9_EE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail21FloatAttributeStorageENS_15TrailingObjectsIS4_JmEEES4_JmEE22getTrailingObjectsImplEPKS4_NS0_19TrailingObjectsBase13OverloadTokenImEE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail25SymbolRefAttributeStorageENS_15TrailingObjectsIS4_JNS2_17FlatSymbolRefAttrEEEES4_JS6_EE22getTrailingObjectsImplEPKS4_NS0_19TrailingObjectsBase13OverloadTokenIS6_EE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail23IntegerAttributeStorageENS_15TrailingObjectsIS4_JmEEES4_JmEE22getTrailingObjectsImplEPKS4_NS0_19TrailingObjectsBase13OverloadTokenImEE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail20FusedLocationStorageENS_15TrailingObjectsIS4_JNS2_8LocationEEEES4_JS6_EE22getTrailingObjectsImplEPKS4_NS0_19TrailingObjectsBase13OverloadTokenIS6_EE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail16TupleTypeStorageENS_15TrailingObjectsIS4_JNS2_4TypeEEEES4_JS6_EE22getTrailingObjectsImplEPKS4_NS0_19TrailingObjectsBase13OverloadTokenIS6_EE |
175 | | |
176 | | static NextTy * |
177 | | getTrailingObjectsImpl(BaseTy *Obj, |
178 | 0 | TrailingObjectsBase::OverloadToken<NextTy>) { |
179 | 0 | auto *Ptr = TopTrailingObj::getTrailingObjectsImpl( |
180 | 0 | Obj, TrailingObjectsBase::OverloadToken<PrevTy>()) + |
181 | 0 | TopTrailingObj::callNumTrailingObjects( |
182 | 0 | Obj, TrailingObjectsBase::OverloadToken<PrevTy>()); |
183 | 0 |
|
184 | 0 | if (requiresRealignment()) |
185 | 0 | return reinterpret_cast<NextTy *>(alignAddr(Ptr, Align::Of<NextTy>())); |
186 | 0 | else |
187 | 0 | return reinterpret_cast<NextTy *>(Ptr); |
188 | 0 | } Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail22TrailingOperandStorageENS_15TrailingObjectsIS4_JNS2_9OpOperandEEEES4_JS6_EE22getTrailingObjectsImplEPS4_NS0_19TrailingObjectsBase13OverloadTokenIS6_EE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir9OperationENS_15TrailingObjectsIS3_JNS2_6detail14InLineOpResultENS5_16TrailingOpResultENS2_12BlockOperandENS2_6RegionENS5_14OperandStorageEEEES8_JS9_SA_EE22getTrailingObjectsImplEPS3_NS0_19TrailingObjectsBase13OverloadTokenIS9_EE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir9OperationENS_15TrailingObjectsIS3_JNS2_6detail14InLineOpResultENS5_16TrailingOpResultENS2_12BlockOperandENS2_6RegionENS5_14OperandStorageEEEES7_JS8_S9_SA_EE22getTrailingObjectsImplEPS3_NS0_19TrailingObjectsBase13OverloadTokenIS8_EE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir9OperationENS_15TrailingObjectsIS3_JNS2_6detail14InLineOpResultENS5_16TrailingOpResultENS2_12BlockOperandENS2_6RegionENS5_14OperandStorageEEEES6_JS7_S8_S9_SA_EE22getTrailingObjectsImplEPS3_NS0_19TrailingObjectsBase13OverloadTokenIS7_EE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir9OperationENS_15TrailingObjectsIS3_JNS2_6detail14InLineOpResultENS5_16TrailingOpResultENS2_12BlockOperandENS2_6RegionENS5_14OperandStorageEEEES3_JS6_S7_S8_S9_SA_EE22getTrailingObjectsImplEPS3_NS0_19TrailingObjectsBase13OverloadTokenIS6_EE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir9OperationENS_15TrailingObjectsIS3_JNS2_6detail14InLineOpResultENS5_16TrailingOpResultENS2_12BlockOperandENS2_6RegionENS5_14OperandStorageEEEES9_JSA_EE22getTrailingObjectsImplEPS3_NS0_19TrailingObjectsBase13OverloadTokenISA_EE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail26DictionaryAttributeStorageENS_15TrailingObjectsIS4_JSt4pairINS2_10IdentifierENS2_9AttributeEEEEES4_JS9_EE22getTrailingObjectsImplEPS4_NS0_19TrailingObjectsBase13OverloadTokenIS9_EE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail21FloatAttributeStorageENS_15TrailingObjectsIS4_JmEEES4_JmEE22getTrailingObjectsImplEPS4_NS0_19TrailingObjectsBase13OverloadTokenImEE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail25SymbolRefAttributeStorageENS_15TrailingObjectsIS4_JNS2_17FlatSymbolRefAttrEEEES4_JS6_EE22getTrailingObjectsImplEPS4_NS0_19TrailingObjectsBase13OverloadTokenIS6_EE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail23IntegerAttributeStorageENS_15TrailingObjectsIS4_JmEEES4_JmEE22getTrailingObjectsImplEPS4_NS0_19TrailingObjectsBase13OverloadTokenImEE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail20FusedLocationStorageENS_15TrailingObjectsIS4_JNS2_8LocationEEEES4_JS6_EE22getTrailingObjectsImplEPS4_NS0_19TrailingObjectsBase13OverloadTokenIS6_EE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail16TupleTypeStorageENS_15TrailingObjectsIS4_JNS2_4TypeEEEES4_JS6_EE22getTrailingObjectsImplEPS4_NS0_19TrailingObjectsBase13OverloadTokenIS6_EE Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail14OperandStorageENS_15TrailingObjectsIS4_JNS2_9OpOperandEEEES4_JS6_EE22getTrailingObjectsImplEPS4_NS0_19TrailingObjectsBase13OverloadTokenIS6_EE |
189 | | |
190 | | // Helper function for TrailingObjects::additionalSizeToAlloc: this |
191 | | // function recurses to superclasses, each of which requires one |
192 | | // fewer size_t argument, and adds its own size. |
193 | | static constexpr size_t additionalSizeToAllocImpl( |
194 | | size_t SizeSoFar, size_t Count1, |
195 | 0 | typename ExtractSecondType<MoreTys, size_t>::type... MoreCounts) { |
196 | 0 | return ParentType::additionalSizeToAllocImpl( |
197 | 0 | (requiresRealignment() ? llvm::alignTo<alignof(NextTy)>(SizeSoFar) |
198 | 0 | : SizeSoFar) + |
199 | 0 | sizeof(NextTy) * Count1, |
200 | 0 | MoreCounts...); |
201 | 0 | } Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail14OperandStorageENS_15TrailingObjectsIS4_JNS2_9OpOperandEEEES4_JS6_EE25additionalSizeToAllocImplEmm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail26DictionaryAttributeStorageENS_15TrailingObjectsIS4_JSt4pairINS2_10IdentifierENS2_9AttributeEEEEES4_JS9_EE25additionalSizeToAllocImplEmm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail21FloatAttributeStorageENS_15TrailingObjectsIS4_JmEEES4_JmEE25additionalSizeToAllocImplEmm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail25SymbolRefAttributeStorageENS_15TrailingObjectsIS4_JNS2_17FlatSymbolRefAttrEEEES4_JS6_EE25additionalSizeToAllocImplEmm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail23IntegerAttributeStorageENS_15TrailingObjectsIS4_JmEEES4_JmEE25additionalSizeToAllocImplEmm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail20FusedLocationStorageENS_15TrailingObjectsIS4_JNS2_8LocationEEEES4_JS6_EE25additionalSizeToAllocImplEmm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail16TupleTypeStorageENS_15TrailingObjectsIS4_JNS2_4TypeEEEES4_JS6_EE25additionalSizeToAllocImplEmm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir9OperationENS_15TrailingObjectsIS3_JNS2_6detail14InLineOpResultENS5_16TrailingOpResultENS2_12BlockOperandENS2_6RegionENS5_14OperandStorageEEEES3_JS6_S7_S8_S9_SA_EE25additionalSizeToAllocImplEmmmmmm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir9OperationENS_15TrailingObjectsIS3_JNS2_6detail14InLineOpResultENS5_16TrailingOpResultENS2_12BlockOperandENS2_6RegionENS5_14OperandStorageEEEES6_JS7_S8_S9_SA_EE25additionalSizeToAllocImplEmmmmm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir9OperationENS_15TrailingObjectsIS3_JNS2_6detail14InLineOpResultENS5_16TrailingOpResultENS2_12BlockOperandENS2_6RegionENS5_14OperandStorageEEEES7_JS8_S9_SA_EE25additionalSizeToAllocImplEmmmm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir9OperationENS_15TrailingObjectsIS3_JNS2_6detail14InLineOpResultENS5_16TrailingOpResultENS2_12BlockOperandENS2_6RegionENS5_14OperandStorageEEEES8_JS9_SA_EE25additionalSizeToAllocImplEmmm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir9OperationENS_15TrailingObjectsIS3_JNS2_6detail14InLineOpResultENS5_16TrailingOpResultENS2_12BlockOperandENS2_6RegionENS5_14OperandStorageEEEES9_JSA_EE25additionalSizeToAllocImplEmm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail22TrailingOperandStorageENS_15TrailingObjectsIS4_JNS2_9OpOperandEEEES4_JS6_EE25additionalSizeToAllocImplEmm |
202 | | }; |
203 | | |
204 | | // The base case of the TrailingObjectsImpl inheritance recursion, |
205 | | // when there's no more trailing types. |
206 | | template <int Align, typename BaseTy, typename TopTrailingObj, typename PrevTy> |
207 | | class TrailingObjectsImpl<Align, BaseTy, TopTrailingObj, PrevTy> |
208 | | : public TrailingObjectsAligner<Align> { |
209 | | protected: |
210 | | // This is a dummy method, only here so the "using" doesn't fail -- |
211 | | // it will never be called, because this function recurses backwards |
212 | | // up the inheritance chain to subclasses. |
213 | | static void getTrailingObjectsImpl(); |
214 | | |
215 | 0 | static constexpr size_t additionalSizeToAllocImpl(size_t SizeSoFar) { |
216 | 0 | return SizeSoFar; |
217 | 0 | } Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail14OperandStorageENS_15TrailingObjectsIS4_JNS2_9OpOperandEEEES6_JEE25additionalSizeToAllocImplEm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail26DictionaryAttributeStorageENS_15TrailingObjectsIS4_JSt4pairINS2_10IdentifierENS2_9AttributeEEEEES9_JEE25additionalSizeToAllocImplEm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail21FloatAttributeStorageENS_15TrailingObjectsIS4_JmEEEmJEE25additionalSizeToAllocImplEm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail25SymbolRefAttributeStorageENS_15TrailingObjectsIS4_JNS2_17FlatSymbolRefAttrEEEES6_JEE25additionalSizeToAllocImplEm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail23IntegerAttributeStorageENS_15TrailingObjectsIS4_JmEEEmJEE25additionalSizeToAllocImplEm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail20FusedLocationStorageENS_15TrailingObjectsIS4_JNS2_8LocationEEEES6_JEE25additionalSizeToAllocImplEm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail16TupleTypeStorageENS_15TrailingObjectsIS4_JNS2_4TypeEEEES6_JEE25additionalSizeToAllocImplEm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir9OperationENS_15TrailingObjectsIS3_JNS2_6detail14InLineOpResultENS5_16TrailingOpResultENS2_12BlockOperandENS2_6RegionENS5_14OperandStorageEEEESA_JEE25additionalSizeToAllocImplEm Unexecuted instantiation: _ZN4llvm25trailing_objects_internal19TrailingObjectsImplILi8EN4mlir6detail22TrailingOperandStorageENS_15TrailingObjectsIS4_JNS2_9OpOperandEEEES6_JEE25additionalSizeToAllocImplEm |
218 | | |
219 | | template <bool CheckAlignment> static void verifyTrailingObjectsAlignment() {} |
220 | | }; |
221 | | |
222 | | } // end namespace trailing_objects_internal |
223 | | |
224 | | // Finally, the main type defined in this file, the one intended for users... |
225 | | |
226 | | /// See the file comment for details on the usage of the |
227 | | /// TrailingObjects type. |
228 | | template <typename BaseTy, typename... TrailingTys> |
229 | | class TrailingObjects : private trailing_objects_internal::TrailingObjectsImpl< |
230 | | trailing_objects_internal::AlignmentCalcHelper< |
231 | | TrailingTys...>::Alignment, |
232 | | BaseTy, TrailingObjects<BaseTy, TrailingTys...>, |
233 | | BaseTy, TrailingTys...> { |
234 | | |
235 | | template <int A, typename B, typename T, typename P, typename... M> |
236 | | friend class trailing_objects_internal::TrailingObjectsImpl; |
237 | | |
238 | | template <typename... Tys> class Foo {}; |
239 | | |
240 | | typedef trailing_objects_internal::TrailingObjectsImpl< |
241 | | trailing_objects_internal::AlignmentCalcHelper<TrailingTys...>::Alignment, |
242 | | BaseTy, TrailingObjects<BaseTy, TrailingTys...>, BaseTy, TrailingTys...> |
243 | | ParentType; |
244 | | using TrailingObjectsBase = trailing_objects_internal::TrailingObjectsBase; |
245 | | |
246 | | using ParentType::getTrailingObjectsImpl; |
247 | | |
248 | | // This function contains only a static_assert BaseTy is final. The |
249 | | // static_assert must be in a function, and not at class-level |
250 | | // because BaseTy isn't complete at class instantiation time, but |
251 | | // will be by the time this function is instantiated. |
252 | 0 | static void verifyTrailingObjectsAssertions() { |
253 | 0 | static_assert(std::is_final<BaseTy>(), "BaseTy must be final."); |
254 | 0 | } Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail22TrailingOperandStorageEJNS1_9OpOperandEEE31verifyTrailingObjectsAssertionsEv Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir9OperationEJNS1_6detail14InLineOpResultENS3_16TrailingOpResultENS1_12BlockOperandENS1_6RegionENS3_14OperandStorageEEE31verifyTrailingObjectsAssertionsEv Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail26DictionaryAttributeStorageEJSt4pairINS1_10IdentifierENS1_9AttributeEEEE31verifyTrailingObjectsAssertionsEv Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail21FloatAttributeStorageEJmEE31verifyTrailingObjectsAssertionsEv Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail25SymbolRefAttributeStorageEJNS1_17FlatSymbolRefAttrEEE31verifyTrailingObjectsAssertionsEv Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail23IntegerAttributeStorageEJmEE31verifyTrailingObjectsAssertionsEv Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail20FusedLocationStorageEJNS1_8LocationEEE31verifyTrailingObjectsAssertionsEv Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail16TupleTypeStorageEJNS1_4TypeEEE31verifyTrailingObjectsAssertionsEv Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail14OperandStorageEJNS1_9OpOperandEEE31verifyTrailingObjectsAssertionsEv |
255 | | |
256 | | // These two methods are the base of the recursion for this method. |
257 | | static const BaseTy * |
258 | | getTrailingObjectsImpl(const BaseTy *Obj, |
259 | 0 | TrailingObjectsBase::OverloadToken<BaseTy>) { |
260 | 0 | return Obj; |
261 | 0 | } Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail26DictionaryAttributeStorageEJSt4pairINS1_10IdentifierENS1_9AttributeEEEE22getTrailingObjectsImplEPKS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail21FloatAttributeStorageEJmEE22getTrailingObjectsImplEPKS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail25SymbolRefAttributeStorageEJNS1_17FlatSymbolRefAttrEEE22getTrailingObjectsImplEPKS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail23IntegerAttributeStorageEJmEE22getTrailingObjectsImplEPKS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail20FusedLocationStorageEJNS1_8LocationEEE22getTrailingObjectsImplEPKS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail16TupleTypeStorageEJNS1_4TypeEEE22getTrailingObjectsImplEPKS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE |
262 | | |
263 | | static BaseTy * |
264 | | getTrailingObjectsImpl(BaseTy *Obj, |
265 | 0 | TrailingObjectsBase::OverloadToken<BaseTy>) { |
266 | 0 | return Obj; |
267 | 0 | } Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail22TrailingOperandStorageEJNS1_9OpOperandEEE22getTrailingObjectsImplEPS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir9OperationEJNS1_6detail14InLineOpResultENS3_16TrailingOpResultENS1_12BlockOperandENS1_6RegionENS3_14OperandStorageEEE22getTrailingObjectsImplEPS2_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS2_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail26DictionaryAttributeStorageEJSt4pairINS1_10IdentifierENS1_9AttributeEEEE22getTrailingObjectsImplEPS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail21FloatAttributeStorageEJmEE22getTrailingObjectsImplEPS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail25SymbolRefAttributeStorageEJNS1_17FlatSymbolRefAttrEEE22getTrailingObjectsImplEPS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail23IntegerAttributeStorageEJmEE22getTrailingObjectsImplEPS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail20FusedLocationStorageEJNS1_8LocationEEE22getTrailingObjectsImplEPS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail16TupleTypeStorageEJNS1_4TypeEEE22getTrailingObjectsImplEPS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail14OperandStorageEJNS1_9OpOperandEEE22getTrailingObjectsImplEPS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE |
268 | | |
269 | | // callNumTrailingObjects simply calls numTrailingObjects on the |
270 | | // provided Obj -- except when the type being queried is BaseTy |
271 | | // itself. There is always only one of the base object, so that case |
272 | | // is handled here. (An additional benefit of indirecting through |
273 | | // this function is that consumers only say "friend |
274 | | // TrailingObjects", and thus, only this class itself can call the |
275 | | // numTrailingObjects function.) |
276 | | static size_t |
277 | | callNumTrailingObjects(const BaseTy *Obj, |
278 | 0 | TrailingObjectsBase::OverloadToken<BaseTy>) { |
279 | 0 | return 1; |
280 | 0 | } Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail22TrailingOperandStorageEJNS1_9OpOperandEEE22callNumTrailingObjectsEPKS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir9OperationEJNS1_6detail14InLineOpResultENS3_16TrailingOpResultENS1_12BlockOperandENS1_6RegionENS3_14OperandStorageEEE22callNumTrailingObjectsEPKS2_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS2_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail26DictionaryAttributeStorageEJSt4pairINS1_10IdentifierENS1_9AttributeEEEE22callNumTrailingObjectsEPKS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail21FloatAttributeStorageEJmEE22callNumTrailingObjectsEPKS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail25SymbolRefAttributeStorageEJNS1_17FlatSymbolRefAttrEEE22callNumTrailingObjectsEPKS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail23IntegerAttributeStorageEJmEE22callNumTrailingObjectsEPKS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail20FusedLocationStorageEJNS1_8LocationEEE22callNumTrailingObjectsEPKS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail16TupleTypeStorageEJNS1_4TypeEEE22callNumTrailingObjectsEPKS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail14OperandStorageEJNS1_9OpOperandEEE22callNumTrailingObjectsEPKS3_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIS3_EE |
281 | | |
282 | | template <typename T> |
283 | | static size_t callNumTrailingObjects(const BaseTy *Obj, |
284 | 0 | TrailingObjectsBase::OverloadToken<T>) { |
285 | 0 | return Obj->numTrailingObjects(TrailingObjectsBase::OverloadToken<T>()); |
286 | 0 | } Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir9OperationEJNS1_6detail14InLineOpResultENS3_16TrailingOpResultENS1_12BlockOperandENS1_6RegionENS3_14OperandStorageEEE22callNumTrailingObjectsIS4_EEmPKS2_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIT_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir9OperationEJNS1_6detail14InLineOpResultENS3_16TrailingOpResultENS1_12BlockOperandENS1_6RegionENS3_14OperandStorageEEE22callNumTrailingObjectsIS5_EEmPKS2_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIT_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir9OperationEJNS1_6detail14InLineOpResultENS3_16TrailingOpResultENS1_12BlockOperandENS1_6RegionENS3_14OperandStorageEEE22callNumTrailingObjectsIS6_EEmPKS2_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIT_EE Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir9OperationEJNS1_6detail14InLineOpResultENS3_16TrailingOpResultENS1_12BlockOperandENS1_6RegionENS3_14OperandStorageEEE22callNumTrailingObjectsIS7_EEmPKS2_NS_25trailing_objects_internal19TrailingObjectsBase13OverloadTokenIT_EE |
287 | | |
288 | | public: |
289 | | // Make this (privately inherited) member public. |
290 | | #ifndef _MSC_VER |
291 | | using ParentType::OverloadToken; |
292 | | #else |
293 | | // MSVC bug prevents the above from working, at least up through CL |
294 | | // 19.10.24629. |
295 | | template <typename T> |
296 | | using OverloadToken = typename ParentType::template OverloadToken<T>; |
297 | | #endif |
298 | | |
299 | | /// Returns a pointer to the trailing object array of the given type |
300 | | /// (which must be one of those specified in the class template). The |
301 | | /// array may have zero or more elements in it. |
302 | 0 | template <typename T> const T *getTrailingObjects() const { |
303 | 0 | verifyTrailingObjectsAssertions(); |
304 | 0 | // Forwards to an impl function with overloads, since member |
305 | 0 | // function templates can't be specialized. |
306 | 0 | return this->getTrailingObjectsImpl( |
307 | 0 | static_cast<const BaseTy *>(this), |
308 | 0 | TrailingObjectsBase::OverloadToken<T>()); |
309 | 0 | } Unexecuted instantiation: _ZNK4llvm15TrailingObjectsIN4mlir6detail26DictionaryAttributeStorageEJSt4pairINS1_10IdentifierENS1_9AttributeEEEE18getTrailingObjectsIS7_EEPKT_v Unexecuted instantiation: _ZNK4llvm15TrailingObjectsIN4mlir6detail21FloatAttributeStorageEJmEE18getTrailingObjectsImEEPKT_v Unexecuted instantiation: _ZNK4llvm15TrailingObjectsIN4mlir6detail25SymbolRefAttributeStorageEJNS1_17FlatSymbolRefAttrEEE18getTrailingObjectsIS4_EEPKT_v Unexecuted instantiation: _ZNK4llvm15TrailingObjectsIN4mlir6detail23IntegerAttributeStorageEJmEE18getTrailingObjectsImEEPKT_v Unexecuted instantiation: _ZNK4llvm15TrailingObjectsIN4mlir6detail20FusedLocationStorageEJNS1_8LocationEEE18getTrailingObjectsIS4_EEPKT_v Unexecuted instantiation: _ZNK4llvm15TrailingObjectsIN4mlir6detail16TupleTypeStorageEJNS1_4TypeEEE18getTrailingObjectsIS4_EEPKT_v |
310 | | |
311 | | /// Returns a pointer to the trailing object array of the given type |
312 | | /// (which must be one of those specified in the class template). The |
313 | | /// array may have zero or more elements in it. |
314 | 0 | template <typename T> T *getTrailingObjects() { |
315 | 0 | verifyTrailingObjectsAssertions(); |
316 | 0 | // Forwards to an impl function with overloads, since member |
317 | 0 | // function templates can't be specialized. |
318 | 0 | return this->getTrailingObjectsImpl( |
319 | 0 | static_cast<BaseTy *>(this), TrailingObjectsBase::OverloadToken<T>()); |
320 | 0 | } Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail22TrailingOperandStorageEJNS1_9OpOperandEEE18getTrailingObjectsIS4_EEPT_v Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir9OperationEJNS1_6detail14InLineOpResultENS3_16TrailingOpResultENS1_12BlockOperandENS1_6RegionENS3_14OperandStorageEEE18getTrailingObjectsIS7_EEPT_v Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir9OperationEJNS1_6detail14InLineOpResultENS3_16TrailingOpResultENS1_12BlockOperandENS1_6RegionENS3_14OperandStorageEEE18getTrailingObjectsIS6_EEPT_v Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir9OperationEJNS1_6detail14InLineOpResultENS3_16TrailingOpResultENS1_12BlockOperandENS1_6RegionENS3_14OperandStorageEEE18getTrailingObjectsIS8_EEPT_v Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir9OperationEJNS1_6detail14InLineOpResultENS3_16TrailingOpResultENS1_12BlockOperandENS1_6RegionENS3_14OperandStorageEEE18getTrailingObjectsIS5_EEPT_v Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir9OperationEJNS1_6detail14InLineOpResultENS3_16TrailingOpResultENS1_12BlockOperandENS1_6RegionENS3_14OperandStorageEEE18getTrailingObjectsIS4_EEPT_v Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail26DictionaryAttributeStorageEJSt4pairINS1_10IdentifierENS1_9AttributeEEEE18getTrailingObjectsIS7_EEPT_v Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail21FloatAttributeStorageEJmEE18getTrailingObjectsImEEPT_v Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail25SymbolRefAttributeStorageEJNS1_17FlatSymbolRefAttrEEE18getTrailingObjectsIS4_EEPT_v Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail23IntegerAttributeStorageEJmEE18getTrailingObjectsImEEPT_v Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail20FusedLocationStorageEJNS1_8LocationEEE18getTrailingObjectsIS4_EEPT_v Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail16TupleTypeStorageEJNS1_4TypeEEE18getTrailingObjectsIS4_EEPT_v Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail14OperandStorageEJNS1_9OpOperandEEE18getTrailingObjectsIS4_EEPT_v |
321 | | |
322 | | /// Returns the size of the trailing data, if an object were |
323 | | /// allocated with the given counts (The counts are in the same order |
324 | | /// as the template arguments). This does not include the size of the |
325 | | /// base object. The template arguments must be the same as those |
326 | | /// used in the class; they are supplied here redundantly only so |
327 | | /// that it's clear what the counts are counting in callers. |
328 | | template <typename... Tys> |
329 | | static constexpr std::enable_if_t< |
330 | | std::is_same<Foo<TrailingTys...>, Foo<Tys...>>::value, size_t> |
331 | | additionalSizeToAlloc(typename trailing_objects_internal::ExtractSecondType< |
332 | 0 | TrailingTys, size_t>::type... Counts) { |
333 | 0 | return ParentType::additionalSizeToAllocImpl(0, Counts...); |
334 | 0 | } |
335 | | |
336 | | /// Returns the total size of an object if it were allocated with the |
337 | | /// given trailing object counts. This is the same as |
338 | | /// additionalSizeToAlloc, except it *does* include the size of the base |
339 | | /// object. |
340 | | template <typename... Tys> |
341 | | static constexpr std::enable_if_t< |
342 | | std::is_same<Foo<TrailingTys...>, Foo<Tys...>>::value, size_t> |
343 | | totalSizeToAlloc(typename trailing_objects_internal::ExtractSecondType< |
344 | 0 | TrailingTys, size_t>::type... Counts) { |
345 | 0 | return sizeof(BaseTy) + ParentType::additionalSizeToAllocImpl(0, Counts...); |
346 | 0 | } Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail26DictionaryAttributeStorageEJSt4pairINS1_10IdentifierENS1_9AttributeEEEE16totalSizeToAllocIJS7_EEENSt9enable_ifIXsr3std7is_sameINS8_3FooIJS7_EEENSB_IJDpT_EEEEE5valueEmE4typeEm Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail21FloatAttributeStorageEJmEE16totalSizeToAllocIJmEEENSt9enable_ifIXsr3std7is_sameINS4_3FooIJmEEENS7_IJDpT_EEEEE5valueEmE4typeEm Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail25SymbolRefAttributeStorageEJNS1_17FlatSymbolRefAttrEEE16totalSizeToAllocIJS4_EEENSt9enable_ifIXsr3std7is_sameINS5_3FooIJS4_EEENS8_IJDpT_EEEEE5valueEmE4typeEm Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail23IntegerAttributeStorageEJmEE16totalSizeToAllocIJmEEENSt9enable_ifIXsr3std7is_sameINS4_3FooIJmEEENS7_IJDpT_EEEEE5valueEmE4typeEm Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail20FusedLocationStorageEJNS1_8LocationEEE16totalSizeToAllocIJS4_EEENSt9enable_ifIXsr3std7is_sameINS5_3FooIJS4_EEENS8_IJDpT_EEEEE5valueEmE4typeEm Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail16TupleTypeStorageEJNS1_4TypeEEE16totalSizeToAllocIJS4_EEENSt9enable_ifIXsr3std7is_sameINS5_3FooIJS4_EEENS8_IJDpT_EEEEE5valueEmE4typeEm Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir9OperationEJNS1_6detail14InLineOpResultENS3_16TrailingOpResultENS1_12BlockOperandENS1_6RegionENS3_14OperandStorageEEE16totalSizeToAllocIJS4_S5_S6_S7_S8_EEENSt9enable_ifIXsr3std7is_sameINS9_3FooIJS4_S5_S6_S7_S8_EEENSC_IJDpT_EEEEE5valueEmE4typeEmmmmm Unexecuted instantiation: _ZN4llvm15TrailingObjectsIN4mlir6detail22TrailingOperandStorageEJNS1_9OpOperandEEE16totalSizeToAllocIJS4_EEENSt9enable_ifIXsr3std7is_sameINS5_3FooIJS4_EEENS8_IJDpT_EEEEE5valueEmE4typeEm |
347 | | |
348 | | /// A type where its ::with_counts template member has a ::type member |
349 | | /// suitable for use as uninitialized storage for an object with the given |
350 | | /// trailing object counts. The template arguments are similar to those |
351 | | /// of additionalSizeToAlloc. |
352 | | /// |
353 | | /// Use with FixedSizeStorageOwner, e.g.: |
354 | | /// |
355 | | /// \code{.cpp} |
356 | | /// |
357 | | /// MyObj::FixedSizeStorage<void *>::with_counts<1u>::type myStackObjStorage; |
358 | | /// MyObj::FixedSizeStorageOwner |
359 | | /// myStackObjOwner(new ((void *)&myStackObjStorage) MyObj); |
360 | | /// MyObj *const myStackObjPtr = myStackObjOwner.get(); |
361 | | /// |
362 | | /// \endcode |
363 | | template <typename... Tys> struct FixedSizeStorage { |
364 | | template <size_t... Counts> struct with_counts { |
365 | | enum { Size = totalSizeToAlloc<Tys...>(Counts...) }; |
366 | | struct type { |
367 | | alignas(BaseTy) char buffer[Size]; |
368 | | }; |
369 | | }; |
370 | | }; |
371 | | |
372 | | /// A type that acts as the owner for an object placed into fixed storage. |
373 | | class FixedSizeStorageOwner { |
374 | | public: |
375 | | FixedSizeStorageOwner(BaseTy *p) : p(p) {} |
376 | | ~FixedSizeStorageOwner() { |
377 | | assert(p && "FixedSizeStorageOwner owns null?"); |
378 | | p->~BaseTy(); |
379 | | } |
380 | | |
381 | | BaseTy *get() { return p; } |
382 | | const BaseTy *get() const { return p; } |
383 | | |
384 | | private: |
385 | | FixedSizeStorageOwner(const FixedSizeStorageOwner &) = delete; |
386 | | FixedSizeStorageOwner(FixedSizeStorageOwner &&) = delete; |
387 | | FixedSizeStorageOwner &operator=(const FixedSizeStorageOwner &) = delete; |
388 | | FixedSizeStorageOwner &operator=(FixedSizeStorageOwner &&) = delete; |
389 | | |
390 | | BaseTy *const p; |
391 | | }; |
392 | | }; |
393 | | |
394 | | } // end namespace llvm |
395 | | |
396 | | #endif |