@@ -167,8 +167,8 @@ bool ReduceCrashingGlobalInitializers::TestGlobalVariables(
167
167
// Convert list to set for fast lookup...
168
168
std::set<GlobalVariable *> GVSet;
169
169
170
- for (unsigned i = 0 , e = GVs. size (); i != e; ++i ) {
171
- GlobalVariable *CMGV = cast<GlobalVariable>(VMap[GVs[i] ]);
170
+ for (GlobalVariable *GV : GVs) {
171
+ GlobalVariable *CMGV = cast<GlobalVariable>(VMap[GV ]);
172
172
assert (CMGV && " Global Variable not in module?!" );
173
173
GVSet.insert (CMGV);
174
174
}
@@ -260,11 +260,11 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function *> &Funcs) {
260
260
261
261
// Convert list to set for fast lookup...
262
262
std::set<Function *> Functions;
263
- for (unsigned i = 0 , e = Funcs. size (); i != e; ++i ) {
264
- Function *CMF = cast<Function>(VMap[Funcs[i] ]);
263
+ for (Function *Func : Funcs) {
264
+ Function *CMF = cast<Function>(VMap[Func ]);
265
265
assert (CMF && " Function not in module?!" );
266
- assert (CMF->getFunctionType () == Funcs[i] ->getFunctionType () && " wrong ty" );
267
- assert (CMF->getName () == Funcs[i] ->getName () && " wrong name" );
266
+ assert (CMF->getFunctionType () == Func ->getFunctionType () && " wrong ty" );
267
+ assert (CMF->getName () == Func ->getName () && " wrong name" );
268
268
Functions.insert (CMF);
269
269
}
270
270
@@ -468,8 +468,8 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock *> &BBs) {
468
468
469
469
// Convert list to set for fast lookup...
470
470
SmallPtrSet<BasicBlock *, 8 > Blocks;
471
- for (unsigned i = 0 , e = BBs. size (); i != e; ++i )
472
- Blocks.insert (cast<BasicBlock>(VMap[BBs[i] ]));
471
+ for (const BasicBlock *BB : BBs)
472
+ Blocks.insert (cast<BasicBlock>(VMap[BB ]));
473
473
474
474
outs () << " Checking for crash with only these blocks:" ;
475
475
unsigned NumPrint = Blocks.size ();
@@ -765,9 +765,9 @@ bool ReduceCrashingInstructions::TestInsts(
765
765
766
766
// Convert list to set for fast lookup...
767
767
SmallPtrSet<Instruction *, 32 > Instructions;
768
- for (unsigned i = 0 , e = Insts. size (); i != e; ++i ) {
769
- assert (!Insts[i] ->isTerminator ());
770
- Instructions.insert (cast<Instruction>(VMap[Insts[i] ]));
768
+ for (const Instruction *Inst : Insts) {
769
+ assert (!Inst ->isTerminator ());
770
+ Instructions.insert (cast<Instruction>(VMap[Inst ]));
771
771
}
772
772
773
773
outs () << " Checking for crash with only " << Instructions.size ();
@@ -776,9 +776,9 @@ bool ReduceCrashingInstructions::TestInsts(
776
776
else
777
777
outs () << " instructions: " ;
778
778
779
- for (Module::iterator MI = M-> begin (), ME = M-> end (); MI != ME; ++MI )
780
- for (Function::iterator FI = MI-> begin (), FE = MI-> end (); FI != FE; ++FI )
781
- for (Instruction &Inst : llvm::make_early_inc_range (*FI )) {
779
+ for (Function &F : *M )
780
+ for (BasicBlock &BB : F )
781
+ for (Instruction &Inst : llvm::make_early_inc_range (BB )) {
782
782
if (!Instructions.count (&Inst) && !Inst.isTerminator () &&
783
783
!Inst.isEHPad () && !Inst.getType ()->isTokenTy () &&
784
784
!Inst.isSwiftError ()) {
@@ -1105,9 +1105,8 @@ static Error ReduceInsts(BugDriver &BD, BugTester TestFn) {
1105
1105
E = BD.getProgram ().end ();
1106
1106
FI != E; ++FI)
1107
1107
if (!FI->isDeclaration ())
1108
- for (Function::const_iterator BI = FI->begin (), E = FI->end (); BI != E;
1109
- ++BI)
1110
- for (BasicBlock::const_iterator I = BI->begin (), E = --BI->end ();
1108
+ for (const BasicBlock &BI : *FI)
1109
+ for (BasicBlock::const_iterator I = BI.begin (), E = --BI.end ();
1111
1110
I != E; ++I, ++CurInstructionNum) {
1112
1111
if (InstructionsToSkipBeforeDeleting) {
1113
1112
--InstructionsToSkipBeforeDeleting;
0 commit comments