@@ -1463,6 +1463,13 @@ template <typename Runtime>
14631463struct TargetFunctionGlobalActorMetadata {
14641464 ConstTargetMetadataPointer<Runtime, swift::TargetMetadata> GlobalActorType;
14651465};
1466+ using FunctionGlobalActorMetadata = TargetFunctionGlobalActorMetadata<InProcess>;
1467+
1468+ template <typename Runtime>
1469+ struct TargetFunctionThrownErrorMetadata {
1470+ ConstTargetMetadataPointer<Runtime, swift::TargetMetadata> ThrownErrorType;
1471+ };
1472+ using FunctionThrownErrorMetadata = TargetFunctionThrownErrorMetadata<InProcess>;
14661473
14671474// / The structure of function type metadata.
14681475template <typename Runtime>
@@ -1472,7 +1479,9 @@ struct TargetFunctionTypeMetadata : public TargetMetadata<Runtime>,
14721479 ConstTargetMetadataPointer<Runtime, swift::TargetMetadata>,
14731480 ParameterFlags,
14741481 TargetFunctionMetadataDifferentiabilityKind<typename Runtime::StoredSize>,
1475- TargetFunctionGlobalActorMetadata<Runtime>> {
1482+ TargetFunctionGlobalActorMetadata<Runtime>,
1483+ ExtendedFunctionTypeFlags,
1484+ TargetFunctionThrownErrorMetadata<Runtime>> {
14761485 using StoredSize = typename Runtime::StoredSize;
14771486 using Parameter = ConstTargetMetadataPointer<Runtime, swift::TargetMetadata>;
14781487
@@ -1483,7 +1492,9 @@ struct TargetFunctionTypeMetadata : public TargetMetadata<Runtime>,
14831492 Parameter,
14841493 ParameterFlags,
14851494 TargetFunctionMetadataDifferentiabilityKind<StoredSize>,
1486- TargetFunctionGlobalActorMetadata<Runtime>>;
1495+ TargetFunctionGlobalActorMetadata<Runtime>,
1496+ ExtendedFunctionTypeFlags,
1497+ TargetFunctionThrownErrorMetadata<Runtime>>;
14871498 friend TrailingObjects;
14881499
14891500 template <typename T>
@@ -1516,6 +1527,16 @@ struct TargetFunctionTypeMetadata : public TargetMetadata<Runtime>,
15161527 return hasGlobalActor () ? 1 : 0 ;
15171528 }
15181529
1530+ size_t numTrailingObjects (OverloadToken<ExtendedFunctionTypeFlags>) const {
1531+ return hasExtendedFlags () ? 1 : 0 ;
1532+ }
1533+
1534+ size_t numTrailingObjects (
1535+ OverloadToken<TargetFunctionThrownErrorMetadata<Runtime>>
1536+ ) const {
1537+ return hasThrownError () ? 1 : 0 ;
1538+ }
1539+
15191540public:
15201541 Parameter *getParameters () {
15211542 return this ->template getTrailingObjects <Parameter>();
@@ -1548,6 +1569,13 @@ struct TargetFunctionTypeMetadata : public TargetMetadata<Runtime>,
15481569 bool hasParameterFlags () const { return Flags.hasParameterFlags (); }
15491570 bool isEscaping () const { return Flags.isEscaping (); }
15501571 bool hasGlobalActor () const { return Flags.hasGlobalActor (); }
1572+ bool hasExtendedFlags () const { return Flags.hasExtendedFlags (); }
1573+ bool hasThrownError () const {
1574+ if (!Flags.hasExtendedFlags ())
1575+ return false ;
1576+
1577+ return getExtendedFlags ().isTypedThrows ();
1578+ }
15511579
15521580 static constexpr StoredSize OffsetToFlags = sizeof (TargetMetadata<Runtime>);
15531581
@@ -1594,6 +1622,35 @@ struct TargetFunctionTypeMetadata : public TargetMetadata<Runtime>,
15941622 this ->template getTrailingObjects <TargetFunctionGlobalActorMetadata<Runtime>>();
15951623 return globalActorAddr->GlobalActorType ;
15961624 }
1625+
1626+ ExtendedFunctionTypeFlags *getExtendedFlagsAddr () {
1627+ assert (hasExtendedFlags ());
1628+ return this ->template getTrailingObjects <ExtendedFunctionTypeFlags>();
1629+ }
1630+
1631+ ExtendedFunctionTypeFlags getExtendedFlags () const {
1632+ if (!hasExtendedFlags ())
1633+ return ExtendedFunctionTypeFlags ();
1634+
1635+ return this ->template getTrailingObjects <ExtendedFunctionTypeFlags>()[0 ];
1636+ }
1637+
1638+ ConstTargetMetadataPointer<Runtime, swift::TargetMetadata> *
1639+ getThrownErrorAddr () {
1640+ assert (hasThrownError ());
1641+ auto thrownErrorAddr =
1642+ this ->template getTrailingObjects <TargetFunctionThrownErrorMetadata<Runtime>>();
1643+ return &thrownErrorAddr->ThrownErrorType ;
1644+ }
1645+
1646+ ConstTargetMetadataPointer<Runtime, swift::TargetMetadata>
1647+ getThrownError () const {
1648+ if (!hasThrownError ())
1649+ return ConstTargetMetadataPointer<Runtime, swift::TargetMetadata>();
1650+ auto thrownErrorAddr =
1651+ this ->template getTrailingObjects <TargetFunctionThrownErrorMetadata<Runtime>>();
1652+ return thrownErrorAddr->ThrownErrorType ;
1653+ }
15971654};
15981655using FunctionTypeMetadata = TargetFunctionTypeMetadata<InProcess>;
15991656
0 commit comments