@@ -1364,62 +1364,52 @@ bool swift::isSimpleType(SILType SILTy, SILModule& Module) {
13641364// / Check if the value of V is computed by means of a simple initialization.
13651365// / Store the actual SILValue into Val and the reversed list of instructions
13661366// / 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 .
13701370bool
13711371swift::analyzeStaticInitializer (SILValue V,
1372- SmallVectorImpl<SILInstruction *> &Insns ) {
1372+ SmallVectorImpl<SILInstruction *> &Insts ) {
13731373 // Save every instruction we see.
13741374 // 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);
13771377
13781378 if (auto *SI = dyn_cast<StructInst>(V)) {
13791379 // If it is not a struct which is a simple type, bail.
13801380 if (!isSimpleType (SI->getType (), SI->getModule ()))
13811381 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+ });
13891386 }
13901387
13911388 if (auto *TI = dyn_cast<TupleInst>(V)) {
13921389 // If it is not a tuple which is a simple type, bail.
13931390 if (!isSimpleType (TI->getType (), TI->getModule ()))
13941391 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+ });
14021396 }
14031397
14041398 if (auto *bi = dyn_cast<BuiltinInst>(V)) {
14051399 switch (bi->getBuiltinInfo ().ID ) {
14061400 case BuiltinValueKind::FPTrunc:
14071401 if (auto *LI = dyn_cast<LiteralInst>(bi->getArguments ()[0 ])) {
1408- return analyzeStaticInitializer (LI, Insns );
1402+ return analyzeStaticInitializer (LI, Insts );
14091403 }
14101404 return false ;
14111405 default :
14121406 return false ;
14131407 }
14141408 }
14151409
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);
14231413}
14241414
14251415// / Replace load sequence which may contain
0 commit comments