@@ -342,12 +342,14 @@ class SILFunctionArgument : public SILArgument {
342342 ValueOwnershipKind ownershipKind, const ValueDecl *decl = nullptr ,
343343 bool isNoImplicitCopy = false ,
344344 LifetimeAnnotation lifetimeAnnotation = LifetimeAnnotation::None,
345- bool isCapture = false )
345+ bool isCapture = false ,
346+ bool isParameterPack = false )
346347 : SILArgument(ValueKind::SILFunctionArgument, parentBlock, type,
347348 ownershipKind, decl) {
348349 sharedUInt32 ().SILFunctionArgument .noImplicitCopy = isNoImplicitCopy;
349350 sharedUInt32 ().SILFunctionArgument .lifetimeAnnotation = lifetimeAnnotation;
350351 sharedUInt32 ().SILFunctionArgument .closureCapture = isCapture;
352+ sharedUInt32 ().SILFunctionArgument .parameterPack = isParameterPack;
351353 }
352354
353355 // A special constructor, only intended for use in
@@ -373,6 +375,23 @@ class SILFunctionArgument : public SILArgument {
373375 sharedUInt32 ().SILFunctionArgument .closureCapture = newValue;
374376 }
375377
378+ // / Is this parameter a pack that corresponds to multiple
379+ // / formal parameters? (This could mean multiple ParamDecl*s,
380+ // / or it could mean a ParamDecl* that's a pack expansion.) Note
381+ // / that not all lowered parameters of pack type are parameter packs:
382+ // / they can be part of a single formal parameter of tuple type.
383+ // / This flag indicates that the lowered parameter has a one-to-many
384+ // / relationship with formal parameters.
385+ // /
386+ // / TODO: preserve the parameter pack references in SIL in a side table
387+ // / instead of using a single bit.
388+ bool isFormalParameterPack () const {
389+ return sharedUInt32 ().SILFunctionArgument .parameterPack ;
390+ }
391+ void setFormalParameterPack (bool isPack) {
392+ sharedUInt32 ().SILFunctionArgument .parameterPack = isPack;
393+ }
394+
376395 LifetimeAnnotation getLifetimeAnnotation () const {
377396 return LifetimeAnnotation::Case (
378397 sharedUInt32 ().SILFunctionArgument .lifetimeAnnotation );
@@ -416,6 +435,7 @@ class SILFunctionArgument : public SILArgument {
416435 setNoImplicitCopy (arg->isNoImplicitCopy ());
417436 setLifetimeAnnotation (arg->getLifetimeAnnotation ());
418437 setClosureCapture (arg->isClosureCapture ());
438+ setFormalParameterPack (arg->isFormalParameterPack ());
419439 }
420440
421441 static bool classof (const SILInstruction *) = delete;
0 commit comments