@@ -279,12 +279,9 @@ class ExpandedTupleInputGenerator {
279
279
ManagedValue elt);
280
280
};
281
281
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 {
288
285
struct OpaquePatternStorage {
289
286
AbstractionPattern origType;
290
287
CanTupleType substType;
@@ -297,9 +294,6 @@ class TupleElementAddressGenerator {
297
294
}
298
295
ExternalUnion<bool , Members, getIndexForKind> origElt;
299
296
300
- // / The address of the tuple value.
301
- ManagedValue tupleAddr;
302
-
303
297
// / If the substituted tuple type contains pack expansions, this is
304
298
// / the induced pack type for the element sequence.
305
299
CanPackType inducedPackType;
@@ -341,12 +335,9 @@ class TupleElementAddressGenerator {
341
335
}
342
336
343
337
public:
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) {
350
341
if (substType->containsPackExpansionType ()) {
351
342
inducedPackType = CanPackType::get (ctx, substType.getElementTypes ());
352
343
}
@@ -420,6 +411,13 @@ class TupleElementAddressGenerator {
420
411
return inducedPackType;
421
412
}
422
413
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
+
423
421
// / Given that we just processed an input, advance to the next,
424
422
// / if there is on.
425
423
// /
@@ -444,6 +442,26 @@ class TupleElementAddressGenerator {
444
442
gen.finish ();
445
443
}
446
444
}
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
+ }
447
465
448
466
// / Project out the current tuple element. Call this exactly once
449
467
// / per element.
0 commit comments