@@ -118,6 +118,8 @@ enum class ImplParameterConvention {
118
118
enum class ImplParameterInfoFlags : uint8_t {
119
119
NotDifferentiable = 0x1 ,
120
120
Sending = 0x2 ,
121
+ Isolated = 0x4 ,
122
+ ImplicitLeading = 0x8
121
123
};
122
124
123
125
using ImplParameterInfoOptions = OptionSet<ImplParameterInfoFlags>;
@@ -192,6 +194,22 @@ class ImplFunctionParam {
192
194
return result;
193
195
}
194
196
197
+ static OptionsType getIsolated () {
198
+ OptionsType result;
199
+
200
+ result |= ImplParameterInfoFlags::Isolated;
201
+
202
+ return result;
203
+ }
204
+
205
+ static OptionsType getImplicitLeading () {
206
+ OptionsType result;
207
+
208
+ result |= ImplParameterInfoFlags::ImplicitLeading;
209
+
210
+ return result;
211
+ }
212
+
195
213
ImplFunctionParam (BuiltType type, ImplParameterConvention convention,
196
214
OptionsType options)
197
215
: Type(type), Convention(convention), Options(options) {}
@@ -1143,11 +1161,11 @@ class TypeDecoder {
1143
1161
return MAKE_NODE_TYPE_ERROR0 (child,
1144
1162
" failed to decode function yields" );
1145
1163
} else if (child->getKind () == NodeKind::ImplResult) {
1146
- if (decodeImplFunctionParam (child, depth + 1 , results))
1164
+ if (decodeImplFunctionResult (child, depth + 1 , results))
1147
1165
return MAKE_NODE_TYPE_ERROR0 (child,
1148
1166
" failed to decode function results" );
1149
1167
} else if (child->getKind () == NodeKind::ImplErrorResult) {
1150
- if (decodeImplFunctionPart (child, depth + 1 , errorResults))
1168
+ if (decodeImplFunctionResult (child, depth + 1 , errorResults))
1151
1169
return MAKE_NODE_TYPE_ERROR0 (child,
1152
1170
" failed to decode function part" );
1153
1171
} else {
@@ -1638,40 +1656,70 @@ class TypeDecoder {
1638
1656
}
1639
1657
1640
1658
template <typename T>
1641
- bool decodeImplFunctionPart (Demangle::NodePointer node, unsigned depth,
1642
- llvm::SmallVectorImpl<T> &results) {
1659
+ bool decodeImplFunctionParam (Demangle::NodePointer node, unsigned depth,
1660
+ llvm::SmallVectorImpl<T> &results) {
1643
1661
if (depth > TypeDecoder::MaxDepth)
1644
1662
return true ;
1645
1663
1646
- if (node->getNumChildren () != 2 )
1664
+ // Children: `convention, attrs, type`
1665
+ // attrs: `differentiability?, sending?, isolated?, implicit_leading?`
1666
+ if (node->getNumChildren () < 2 )
1647
1667
return true ;
1648
-
1649
- if (node->getChild (0 )->getKind () != Node::Kind::ImplConvention ||
1650
- node->getChild (1 )->getKind () != Node::Kind::Type)
1668
+
1669
+ auto *conventionNode = node->getChild (0 );
1670
+ auto *typeNode = node->getLastChild ();
1671
+ if (conventionNode->getKind () != Node::Kind::ImplConvention ||
1672
+ typeNode->getKind () != Node::Kind::Type)
1651
1673
return true ;
1652
1674
1653
- StringRef conventionString = node->getChild (0 )->getText ();
1654
- std::optional<typename T::ConventionType> convention =
1655
- T::getConventionFromString (conventionString);
1675
+ StringRef conventionString = conventionNode->getText ();
1676
+ auto convention = T::getConventionFromString (conventionString);
1656
1677
if (!convention)
1657
1678
return true ;
1658
- auto type = decodeMangledType (node-> getChild ( 1 ) , depth + 1 );
1659
- if (type .isError ())
1679
+ auto result = decodeMangledType (typeNode , depth + 1 );
1680
+ if (result .isError ())
1660
1681
return true ;
1661
1682
1662
- results.emplace_back (type.getType (), *convention);
1683
+ typename T::OptionsType options;
1684
+ for (unsigned i = 1 ; i < node->getNumChildren () - 1 ; ++i) {
1685
+ auto child = node->getChild (i);
1686
+ switch (child->getKind ()) {
1687
+ case Node::Kind::ImplParameterResultDifferentiability: {
1688
+ auto optDiffOptions =
1689
+ T::getDifferentiabilityFromString (child->getText ());
1690
+ if (!optDiffOptions)
1691
+ return true ;
1692
+ options |= *optDiffOptions;
1693
+ break ;
1694
+ }
1695
+ case Node::Kind::ImplParameterSending:
1696
+ options |= T::getSending ();
1697
+ break ;
1698
+ case Node::Kind::ImplParameterIsolated:
1699
+ options |= T::getIsolated ();
1700
+ break ;
1701
+ case Node::Kind::ImplParameterImplicitLeading:
1702
+ options |= T::getImplicitLeading ();
1703
+ break ;
1704
+ default :
1705
+ return true ;
1706
+ }
1707
+ }
1708
+
1709
+ results.emplace_back (result.getType (), *convention, options);
1710
+
1663
1711
return false ;
1664
1712
}
1665
1713
1666
1714
template <typename T>
1667
- bool decodeImplFunctionParam (Demangle::NodePointer node, unsigned depth,
1668
- llvm::SmallVectorImpl<T> &results) {
1715
+ bool decodeImplFunctionResult (Demangle::NodePointer node, unsigned depth,
1716
+ llvm::SmallVectorImpl<T> &results) {
1669
1717
if (depth > TypeDecoder::MaxDepth)
1670
1718
return true ;
1671
1719
1672
- // Children: `convention, differentiability?, sending? , type`
1673
- if (node-> getNumChildren () != 2 && node-> getNumChildren () != 3 &&
1674
- node->getNumChildren () != 4 )
1720
+ // Children: `convention, attrs , type`
1721
+ // attrs: `differentiability?, sending?, isolated?, implicit_leading?`
1722
+ if ( node->getNumChildren () < 2 )
1675
1723
return true ;
1676
1724
1677
1725
auto *conventionNode = node->getChild (0 );
@@ -1689,23 +1737,23 @@ class TypeDecoder {
1689
1737
return true ;
1690
1738
1691
1739
typename T::OptionsType options;
1692
- if (node-> getNumChildren () == 3 || node->getNumChildren () == 4 ) {
1693
- auto diffKindNode = node->getChild (1 );
1694
- if (diffKindNode ->getKind () !=
1695
- Node::Kind::ImplParameterResultDifferentiability)
1696
- return true ;
1697
- auto optDiffOptions =
1698
- T::getDifferentiabilityFromString (diffKindNode-> getText ());
1699
- if (!optDiffOptions)
1700
- return true ;
1701
- options |= *optDiffOptions ;
1702
- }
1703
-
1704
- if (node-> getNumChildren () == 4 ) {
1705
- auto sendingKindNode = node-> getChild ( 2 ) ;
1706
- if (sendingKindNode-> getKind () != Node::Kind::ImplParameterSending)
1740
+ for ( unsigned i = 1 ; i < node->getNumChildren () - 1 ; ++i ) {
1741
+ auto child = node->getChild (i );
1742
+ switch (child ->getKind ()) {
1743
+ case Node::Kind::ImplParameterResultDifferentiability: {
1744
+ auto optDiffOptions =
1745
+ T::getDifferentiabilityFromString (child-> getText ());
1746
+ if (!optDiffOptions)
1747
+ return true ;
1748
+ options |= *optDiffOptions ;
1749
+ break ;
1750
+ }
1751
+ case Node::Kind::ImplParameterSending:
1752
+ options |= T::getSending ();
1753
+ break ;
1754
+ default :
1707
1755
return true ;
1708
- options |= T::getSending ();
1756
+ }
1709
1757
}
1710
1758
1711
1759
results.emplace_back (result.getType (), *convention, options);
0 commit comments