@@ -279,12 +279,9 @@ class ExpandedTupleInputGenerator {
279279 ManagedValue elt);
280280};
281281
282- // / A generator for visiting the addresses of the elements of
283- // / a tuple. Unlike the other tuple generators, this does not
284- // / require the original abstraction pattern to be a tuple pattern:
285- // / like forEachExpandedTupleElement, it permits an opaque
286- // / abstraction pattern.
287- class TupleElementAddressGenerator {
282+ // / A generator for visiting the substituted elements of a tuple
283+ // / (unlike TupleElementGenerator, which visits the orig elements).
284+ class TupleSubstElementGenerator {
288285 struct OpaquePatternStorage {
289286 AbstractionPattern origType;
290287 CanTupleType substType;
@@ -297,9 +294,6 @@ class TupleElementAddressGenerator {
297294 }
298295 ExternalUnion<bool , Members, getIndexForKind> origElt;
299296
300- // / The address of the tuple value.
301- ManagedValue tupleAddr;
302-
303297 // / If the substituted tuple type contains pack expansions, this is
304298 // / the induced pack type for the element sequence.
305299 CanPackType inducedPackType;
@@ -341,12 +335,9 @@ class TupleElementAddressGenerator {
341335 }
342336
343337public:
344- TupleElementAddressGenerator (const ASTContext &ctx,
345- ManagedValue tupleAddr,
346- AbstractionPattern origType,
347- CanTupleType substType)
348- : tupleAddr(tupleAddr) {
349-
338+ TupleSubstElementGenerator (const ASTContext &ctx,
339+ AbstractionPattern origType,
340+ CanTupleType substType) {
350341 if (substType->containsPackExpansionType ()) {
351342 inducedPackType = CanPackType::get (ctx, substType.getElementTypes ());
352343 }
@@ -420,6 +411,13 @@ class TupleElementAddressGenerator {
420411 return inducedPackType;
421412 }
422413
414+ // / Return the induced pack type if the substituted tuple contains
415+ // / pack expansions or null if it does not. Suitable for use with
416+ // / e.g. enterDestroyRemainingTupleComponentsCleanup.
417+ CanPackType getInducedPackTypeIfPresent () const {
418+ return inducedPackType;
419+ }
420+
423421 // / Given that we just processed an input, advance to the next,
424422 // / if there is on.
425423 // /
@@ -444,6 +442,26 @@ class TupleElementAddressGenerator {
444442 gen.finish ();
445443 }
446444 }
445+ };
446+
447+ // / A generator for visiting the addresses of the elements of
448+ // / a tuple. Unlike the other tuple generators, this does not
449+ // / require the original abstraction pattern to be a tuple pattern:
450+ // / like forEachExpandedTupleElement, it permits an opaque
451+ // / abstraction pattern.
452+ class TupleElementAddressGenerator : public TupleSubstElementGenerator {
453+ // / The address of the tuple value.
454+ ManagedValue tupleAddr;
455+
456+ public:
457+ TupleElementAddressGenerator (const ASTContext &ctx,
458+ ManagedValue tupleAddr,
459+ AbstractionPattern origType,
460+ CanTupleType substType)
461+ : TupleSubstElementGenerator(ctx, origType, substType),
462+ tupleAddr (tupleAddr) {
463+ assert (tupleAddr.getType ().isAddress ());
464+ }
447465
448466 // / Project out the current tuple element. Call this exactly once
449467 // / per element.
0 commit comments