@@ -1364,62 +1364,52 @@ bool swift::isSimpleType(SILType SILTy, SILModule& Module) {
1364
1364
// / Check if the value of V is computed by means of a simple initialization.
1365
1365
// / Store the actual SILValue into Val and the reversed list of instructions
1366
1366
// / initializing it in Insns.
1367
- // / The check is performed by recursively walking the computation of the
1368
- // / SIL value being analyzed.
1369
- // / TODO: Move into utils .
1367
+ // /
1368
+ // / The check is performed by recursively walking the computation of the SIL
1369
+ // / value being analyzed .
1370
1370
bool
1371
1371
swift::analyzeStaticInitializer (SILValue V,
1372
- SmallVectorImpl<SILInstruction *> &Insns ) {
1372
+ SmallVectorImpl<SILInstruction *> &Insts ) {
1373
1373
// Save every instruction we see.
1374
1374
// TODO: MultiValueInstruction?
1375
- if (auto I = dyn_cast<SingleValueInstruction>(V))
1376
- Insns .push_back (I);
1375
+ if (auto * I = dyn_cast<SingleValueInstruction>(V))
1376
+ Insts .push_back (I);
1377
1377
1378
1378
if (auto *SI = dyn_cast<StructInst>(V)) {
1379
1379
// If it is not a struct which is a simple type, bail.
1380
1380
if (!isSimpleType (SI->getType (), SI->getModule ()))
1381
1381
return false ;
1382
- for (auto &Op: SI->getAllOperands ()) {
1383
- // If one of the struct instruction operands is not
1384
- // a simple initializer, bail.
1385
- if (!analyzeStaticInitializer (Op.get (), Insns))
1386
- return false ;
1387
- }
1388
- return true ;
1382
+ return llvm::none_of (SI->getAllOperands (),
1383
+ [&](Operand &Op) -> bool {
1384
+ return !analyzeStaticInitializer (Op.get (), Insts);
1385
+ });
1389
1386
}
1390
1387
1391
1388
if (auto *TI = dyn_cast<TupleInst>(V)) {
1392
1389
// If it is not a tuple which is a simple type, bail.
1393
1390
if (!isSimpleType (TI->getType (), TI->getModule ()))
1394
1391
return false ;
1395
- for (auto &Op: TI->getAllOperands ()) {
1396
- // If one of the struct instruction operands is not
1397
- // a simple initializer, bail.
1398
- if (!analyzeStaticInitializer (Op.get (), Insns))
1399
- return false ;
1400
- }
1401
- return true ;
1392
+ return llvm::none_of (TI->getAllOperands (),
1393
+ [&](Operand &Op) -> bool {
1394
+ return !analyzeStaticInitializer (Op.get (), Insts);
1395
+ });
1402
1396
}
1403
1397
1404
1398
if (auto *bi = dyn_cast<BuiltinInst>(V)) {
1405
1399
switch (bi->getBuiltinInfo ().ID ) {
1406
1400
case BuiltinValueKind::FPTrunc:
1407
1401
if (auto *LI = dyn_cast<LiteralInst>(bi->getArguments ()[0 ])) {
1408
- return analyzeStaticInitializer (LI, Insns );
1402
+ return analyzeStaticInitializer (LI, Insts );
1409
1403
}
1410
1404
return false ;
1411
1405
default :
1412
1406
return false ;
1413
1407
}
1414
1408
}
1415
1409
1416
- if (isa<IntegerLiteralInst>(V)
1417
- || isa<FloatLiteralInst>(V)
1418
- || isa<StringLiteralInst>(V)) {
1419
- return true ;
1420
- }
1421
-
1422
- return false ;
1410
+ return isa<IntegerLiteralInst>(V)
1411
+ || isa<FloatLiteralInst>(V)
1412
+ || isa<StringLiteralInst>(V);
1423
1413
}
1424
1414
1425
1415
// / Replace load sequence which may contain
0 commit comments