@@ -176,6 +176,17 @@ enum HasPack_t : bool {
176176 HasPack = true ,
177177};
178178
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+
179190// / Extended type information used by SIL.
180191class TypeLowering {
181192public:
@@ -184,15 +195,16 @@ class TypeLowering {
184195 //
185196 // clang-format off
186197 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 ,
196208 };
197209 // clang-format on
198210
@@ -209,15 +221,17 @@ class TypeLowering {
209221 IsTypeExpansionSensitive_t isTypeExpansionSensitive =
210222 IsNotTypeExpansionSensitive,
211223 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)
213226 : Flags((isTrivial ? 0U : NonTrivialFlag) |
214227 (isFixedABI ? 0U : NonFixedABIFlag) |
215228 (isAddressOnly ? AddressOnlyFlag : 0U ) |
216229 (isResilient ? ResilientFlag : 0U ) |
217230 (isTypeExpansionSensitive ? TypeExpansionSensitiveFlag : 0U ) |
218231 (hasRawPointer ? HasRawPointerFlag : 0U ) |
219232 (isLexical ? LexicalFlag : 0U ) |
220- (hasPack ? HasPackFlag : 0U )) {}
233+ (hasPack ? HasPackFlag : 0U ) |
234+ (isAFD ? AddressableForDependenciesFlag : 0U )) {}
221235
222236 constexpr bool operator ==(RecursiveProperties p) const {
223237 return Flags == p.Flags ;
@@ -227,6 +241,12 @@ class TypeLowering {
227241 return {IsTrivial, IsFixedABI, IsNotAddressOnly, IsNotResilient};
228242 }
229243
244+ static constexpr RecursiveProperties forTrivialOpaque () {
245+ return {IsTrivial, IsFixedABI, IsNotAddressOnly, IsNotResilient,
246+ IsNotTypeExpansionSensitive, HasRawPointer, IsNotLexical,
247+ HasNoPack, IsAddressableForDependencies};
248+ }
249+
230250 static constexpr RecursiveProperties forRawPointer () {
231251 return {IsTrivial, IsFixedABI, IsNotAddressOnly, IsNotResilient,
232252 IsNotTypeExpansionSensitive, HasRawPointer};
@@ -239,11 +259,14 @@ class TypeLowering {
239259
240260 static constexpr RecursiveProperties forOpaque () {
241261 return {IsNotTrivial, IsNotFixedABI, IsAddressOnly, IsNotResilient,
242- IsNotTypeExpansionSensitive, DoesNotHaveRawPointer, IsLexical, HasNoPack};
262+ IsNotTypeExpansionSensitive, HasRawPointer, IsLexical,
263+ HasNoPack, IsAddressableForDependencies};
243264 }
244265
245266 static constexpr RecursiveProperties forResilient () {
246- return {IsTrivial, IsFixedABI, IsNotAddressOnly, IsResilient};
267+ return {IsTrivial, IsFixedABI, IsNotAddressOnly, IsResilient,
268+ IsNotTypeExpansionSensitive, HasRawPointer, IsNotLexical,
269+ HasNoPack, IsAddressableForDependencies};
247270 }
248271
249272 void addSubobject (RecursiveProperties other) {
@@ -278,6 +301,10 @@ class TypeLowering {
278301 HasPack_t isOrContainsPack () const {
279302 return HasPack_t ((Flags & HasPackFlag) != 0 );
280303 }
304+ IsAddressableForDependencies_t isAddressableForDependencies () const {
305+ return IsAddressableForDependencies_t (
306+ (Flags & AddressableForDependenciesFlag) != 0 );
307+ }
281308
282309 void setNonTrivial () { Flags |= NonTrivialFlag; }
283310 void setIsOrContainsRawPointer () { Flags |= HasRawPointerFlag; }
@@ -294,6 +321,9 @@ class TypeLowering {
294321 Flags = (Flags & ~LexicalFlag) | (isLexical ? LexicalFlag : 0 );
295322 }
296323 void setHasPack () { Flags |= HasPackFlag; }
324+ void setAddressableForDependencies () {
325+ Flags |= AddressableForDependenciesFlag;
326+ }
297327 };
298328
299329private:
0 commit comments