@@ -176,6 +176,17 @@ enum HasPack_t : bool {
176
176
HasPack = true ,
177
177
};
178
178
179
+ // / Is the type addressable-for-dependencies?
180
+ // /
181
+ // / Values of an addressable-for-dependency type are passed indirectly into
182
+ // / functions that specify a return value lifetime dependency on the value.
183
+ // / This allows the dependent value to safely contain pointers to the in-memory
184
+ // / representation of the source of the dependency.
185
+ enum IsAddressableForDependencies_t : bool {
186
+ IsNotAddressableForDependencies = false ,
187
+ IsAddressableForDependencies = true ,
188
+ };
189
+
179
190
// / Extended type information used by SIL.
180
191
class TypeLowering {
181
192
public:
@@ -184,15 +195,16 @@ class TypeLowering {
184
195
//
185
196
// clang-format off
186
197
enum : unsigned {
187
- NonTrivialFlag = 1 << 0 ,
188
- NonFixedABIFlag = 1 << 1 ,
189
- AddressOnlyFlag = 1 << 2 ,
190
- ResilientFlag = 1 << 3 ,
191
- TypeExpansionSensitiveFlag = 1 << 4 ,
192
- InfiniteFlag = 1 << 5 ,
193
- HasRawPointerFlag = 1 << 6 ,
194
- LexicalFlag = 1 << 7 ,
195
- HasPackFlag = 1 << 8 ,
198
+ NonTrivialFlag = 1 << 0 ,
199
+ NonFixedABIFlag = 1 << 1 ,
200
+ AddressOnlyFlag = 1 << 2 ,
201
+ ResilientFlag = 1 << 3 ,
202
+ TypeExpansionSensitiveFlag = 1 << 4 ,
203
+ InfiniteFlag = 1 << 5 ,
204
+ HasRawPointerFlag = 1 << 6 ,
205
+ LexicalFlag = 1 << 7 ,
206
+ HasPackFlag = 1 << 8 ,
207
+ AddressableForDependenciesFlag = 1 << 9 ,
196
208
};
197
209
// clang-format on
198
210
@@ -209,15 +221,17 @@ class TypeLowering {
209
221
IsTypeExpansionSensitive_t isTypeExpansionSensitive =
210
222
IsNotTypeExpansionSensitive,
211
223
HasRawPointer_t hasRawPointer = DoesNotHaveRawPointer,
212
- IsLexical_t isLexical = IsNotLexical, HasPack_t hasPack = HasNoPack)
224
+ IsLexical_t isLexical = IsNotLexical, HasPack_t hasPack = HasNoPack,
225
+ IsAddressableForDependencies_t isAFD = IsAddressableForDependencies)
213
226
: Flags((isTrivial ? 0U : NonTrivialFlag) |
214
227
(isFixedABI ? 0U : NonFixedABIFlag) |
215
228
(isAddressOnly ? AddressOnlyFlag : 0U ) |
216
229
(isResilient ? ResilientFlag : 0U ) |
217
230
(isTypeExpansionSensitive ? TypeExpansionSensitiveFlag : 0U ) |
218
231
(hasRawPointer ? HasRawPointerFlag : 0U ) |
219
232
(isLexical ? LexicalFlag : 0U ) |
220
- (hasPack ? HasPackFlag : 0U )) {}
233
+ (hasPack ? HasPackFlag : 0U ) |
234
+ (isAFD ? AddressableForDependenciesFlag : 0U )) {}
221
235
222
236
constexpr bool operator ==(RecursiveProperties p) const {
223
237
return Flags == p.Flags ;
@@ -227,6 +241,12 @@ class TypeLowering {
227
241
return {IsTrivial, IsFixedABI, IsNotAddressOnly, IsNotResilient};
228
242
}
229
243
244
+ static constexpr RecursiveProperties forTrivialOpaque () {
245
+ return {IsTrivial, IsFixedABI, IsNotAddressOnly, IsNotResilient,
246
+ IsNotTypeExpansionSensitive, HasRawPointer, IsNotLexical,
247
+ HasNoPack, IsAddressableForDependencies};
248
+ }
249
+
230
250
static constexpr RecursiveProperties forRawPointer () {
231
251
return {IsTrivial, IsFixedABI, IsNotAddressOnly, IsNotResilient,
232
252
IsNotTypeExpansionSensitive, HasRawPointer};
@@ -239,11 +259,14 @@ class TypeLowering {
239
259
240
260
static constexpr RecursiveProperties forOpaque () {
241
261
return {IsNotTrivial, IsNotFixedABI, IsAddressOnly, IsNotResilient,
242
- IsNotTypeExpansionSensitive, DoesNotHaveRawPointer, IsLexical, HasNoPack};
262
+ IsNotTypeExpansionSensitive, HasRawPointer, IsLexical,
263
+ HasNoPack, IsAddressableForDependencies};
243
264
}
244
265
245
266
static constexpr RecursiveProperties forResilient () {
246
- return {IsTrivial, IsFixedABI, IsNotAddressOnly, IsResilient};
267
+ return {IsTrivial, IsFixedABI, IsNotAddressOnly, IsResilient,
268
+ IsNotTypeExpansionSensitive, HasRawPointer, IsNotLexical,
269
+ HasNoPack, IsAddressableForDependencies};
247
270
}
248
271
249
272
void addSubobject (RecursiveProperties other) {
@@ -278,6 +301,10 @@ class TypeLowering {
278
301
HasPack_t isOrContainsPack () const {
279
302
return HasPack_t ((Flags & HasPackFlag) != 0 );
280
303
}
304
+ IsAddressableForDependencies_t isAddressableForDependencies () const {
305
+ return IsAddressableForDependencies_t (
306
+ (Flags & AddressableForDependenciesFlag) != 0 );
307
+ }
281
308
282
309
void setNonTrivial () { Flags |= NonTrivialFlag; }
283
310
void setIsOrContainsRawPointer () { Flags |= HasRawPointerFlag; }
@@ -294,6 +321,9 @@ class TypeLowering {
294
321
Flags = (Flags & ~LexicalFlag) | (isLexical ? LexicalFlag : 0 );
295
322
}
296
323
void setHasPack () { Flags |= HasPackFlag; }
324
+ void setAddressableForDependencies () {
325
+ Flags |= AddressableForDependenciesFlag;
326
+ }
297
327
};
298
328
299
329
private:
0 commit comments