@@ -333,26 +333,15 @@ static ManagedValue emitManagedParameter(SILGenFunction &SGF, SILLocation loc,
333
333
llvm_unreachable (" bad convention" );
334
334
}
335
335
336
- static void expandTupleTypes (CanType type, SmallVectorImpl<CanType> &results) {
337
- if (auto tuple = dyn_cast<TupleType>(type)) {
338
- for (auto eltType : tuple.getElementTypes ())
339
- expandTupleTypes (eltType, results);
340
- } else {
341
- results.push_back (type);
342
- }
343
- }
344
-
345
- // / Recursively expand all the tuples in the given parameter list.
346
- // / Callers assume that the resulting array will line up with the
347
- // / SILFunctionType's parameter list, which is true as along as there
348
- // / aren't any indirectly-passed tuples; we should be safe from that
349
- // / here in the bridging code.
336
+ // / Get the type of each parameter, filtering out empty tuples.
350
337
static SmallVector<CanType, 8 >
351
- expandTupleTypes (AnyFunctionType::CanParamArrayRef params) {
338
+ getParameterTypes (AnyFunctionType::CanParamArrayRef params) {
352
339
SmallVector<CanType, 8 > results;
353
340
for (auto param : params) {
354
341
assert (!param.isInOut () && !param.isVariadic ());
355
- expandTupleTypes (param.getPlainType (), results);
342
+ if (param.getPlainType ()->isVoid ())
343
+ continue ;
344
+ results.push_back (param.getPlainType ());
356
345
}
357
346
return results;
358
347
}
@@ -403,8 +392,8 @@ static void buildFuncToBlockInvokeBody(SILGenFunction &SGF,
403
392
assert (blockTy->getParameters ().size () == funcTy->getParameters ().size ()
404
393
&& " block and function types don't match" );
405
394
406
- auto nativeParamTypes = expandTupleTypes (formalFuncType.getParams ());
407
- auto bridgedParamTypes = expandTupleTypes (formalBlockType.getParams ());
395
+ auto nativeParamTypes = getParameterTypes (formalFuncType.getParams ());
396
+ auto bridgedParamTypes = getParameterTypes (formalBlockType.getParams ());
408
397
409
398
SmallVector<ManagedValue, 4 > args;
410
399
for (unsigned i : indices (funcTy->getParameters ())) {
@@ -839,8 +828,8 @@ static void buildBlockToFuncThunkBody(SILGenFunction &SGF,
839
828
}
840
829
}
841
830
842
- auto formalBlockParams = expandTupleTypes (formalBlockTy.getParams ());
843
- auto formalFuncParams = expandTupleTypes (formalFuncTy.getParams ());
831
+ auto formalBlockParams = getParameterTypes (formalBlockTy.getParams ());
832
+ auto formalFuncParams = getParameterTypes (formalFuncTy.getParams ());
844
833
assert (formalBlockParams.size () == blockTy->getNumParameters ());
845
834
assert (formalFuncParams.size () == funcTy->getNumParameters ());
846
835
@@ -1297,10 +1286,10 @@ static SILFunctionType *emitObjCThunkArguments(SILGenFunction &SGF,
1297
1286
assert (objcFnTy->getNumIndirectFormalResults () == 0
1298
1287
&& " Objective-C methods cannot have indirect results" );
1299
1288
1300
- auto bridgedFormalTypes = expandTupleTypes (objcFormalFnTy.getParams ());
1289
+ auto bridgedFormalTypes = getParameterTypes (objcFormalFnTy.getParams ());
1301
1290
bridgedFormalResultTy = objcFormalFnTy.getResult ();
1302
1291
1303
- auto nativeFormalTypes = expandTupleTypes (swiftFormalFnTy.getParams ());
1292
+ auto nativeFormalTypes = getParameterTypes (swiftFormalFnTy.getParams ());
1304
1293
nativeFormalResultTy = swiftFormalFnTy.getResult ();
1305
1294
1306
1295
// Emit the other arguments, taking ownership of arguments if necessary.
@@ -1697,9 +1686,9 @@ void SILGenFunction::emitForeignToNativeThunk(SILDeclRef thunk) {
1697
1686
1698
1687
{
1699
1688
auto foreignFormalParams =
1700
- expandTupleTypes (foreignCI.LoweredType .getParams ());
1689
+ getParameterTypes (foreignCI.LoweredType .getParams ());
1701
1690
auto nativeFormalParams =
1702
- expandTupleTypes (nativeCI.LoweredType .getParams ());
1691
+ getParameterTypes (nativeCI.LoweredType .getParams ());
1703
1692
1704
1693
for (unsigned nativeParamIndex : indices (params)) {
1705
1694
// Bring the parameter to +1.
0 commit comments