@@ -1255,6 +1255,64 @@ class AbstractionPattern {
12551255 llvm_unreachable (" bad kind" );
12561256 }
12571257
1258+ // / Is the given pack type a valid substitution of this abstraction
1259+ // / pattern?
1260+ bool matchesPack (CanPackType substType);
1261+
1262+ bool isPack () const {
1263+ switch (getKind ()) {
1264+ case Kind::Invalid:
1265+ llvm_unreachable (" querying invalid abstraction pattern!" );
1266+ case Kind::Opaque:
1267+ case Kind::PartialCurriedObjCMethodType:
1268+ case Kind::CurriedObjCMethodType:
1269+ case Kind::CFunctionAsMethodType:
1270+ case Kind::CurriedCFunctionAsMethodType:
1271+ case Kind::PartialCurriedCFunctionAsMethodType:
1272+ case Kind::ObjCMethodType:
1273+ case Kind::CXXMethodType:
1274+ case Kind::CurriedCXXMethodType:
1275+ case Kind::PartialCurriedCXXMethodType:
1276+ case Kind::OpaqueFunction:
1277+ case Kind::OpaqueDerivativeFunction:
1278+ case Kind::ObjCCompletionHandlerArgumentsType:
1279+ case Kind::Tuple:
1280+ case Kind::ClangType:
1281+ return false ;
1282+ case Kind::Type:
1283+ case Kind::Discard:
1284+ return isa<PackType>(getType ());
1285+ }
1286+ llvm_unreachable (" bad kind" );
1287+ }
1288+
1289+ size_t getNumPackElements () const {
1290+ switch (getKind ()) {
1291+ case Kind::Invalid:
1292+ llvm_unreachable (" querying invalid abstraction pattern!" );
1293+ case Kind::Opaque:
1294+ case Kind::PartialCurriedObjCMethodType:
1295+ case Kind::CurriedObjCMethodType:
1296+ case Kind::CFunctionAsMethodType:
1297+ case Kind::CurriedCFunctionAsMethodType:
1298+ case Kind::PartialCurriedCFunctionAsMethodType:
1299+ case Kind::ObjCMethodType:
1300+ case Kind::CXXMethodType:
1301+ case Kind::CurriedCXXMethodType:
1302+ case Kind::PartialCurriedCXXMethodType:
1303+ case Kind::OpaqueFunction:
1304+ case Kind::OpaqueDerivativeFunction:
1305+ case Kind::ObjCCompletionHandlerArgumentsType:
1306+ case Kind::Tuple:
1307+ case Kind::ClangType:
1308+ llvm_unreachable (" pattern is not a pack" );
1309+ case Kind::Type:
1310+ case Kind::Discard:
1311+ return cast<PackType>(getType ())->getNumElements ();
1312+ }
1313+ llvm_unreachable (" bad kind" );
1314+ }
1315+
12581316 // / Given that the value being abstracted is a move only type, return the
12591317 // / abstraction pattern with the move only bit removed.
12601318 AbstractionPattern removingMoveOnlyWrapper () const ;
@@ -1264,9 +1322,21 @@ class AbstractionPattern {
12641322 AbstractionPattern addingMoveOnlyWrapper () const ;
12651323
12661324 // / Given that the value being abstracted is a tuple type, return
1267- // / the abstraction pattern for its object type.
1325+ // / the abstraction pattern for an element type.
12681326 AbstractionPattern getTupleElementType (unsigned index) const ;
12691327
1328+ // / Given that the value being abstracted is a pack type, return
1329+ // / the abstraction pattern for an element type.
1330+ AbstractionPattern getPackElementType (unsigned index) const ;
1331+
1332+ // / Give that the value being abstracted is a pack expansion type, return the
1333+ // / underlying pattern type.
1334+ AbstractionPattern getPackExpansionPatternType () const ;
1335+
1336+ // / Give that the value being abstracted is a pack expansion type, return the
1337+ // / underlying count type.
1338+ AbstractionPattern getPackExpansionCountType () const ;
1339+
12701340 // / Given that the value being abstracted is a function, return the
12711341 // / abstraction pattern for its result type.
12721342 AbstractionPattern getFunctionResultType () const ;
0 commit comments