Skip to content

Commit 852b11c

Browse files
[bugpoint] Use range-based for loops (NFC) (#140438)
1 parent 159f05f commit 852b11c

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

llvm/tools/bugpoint/CrashDebugger.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ bool ReduceCrashingGlobalInitializers::TestGlobalVariables(
167167
// Convert list to set for fast lookup...
168168
std::set<GlobalVariable *> GVSet;
169169

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]);
172172
assert(CMGV && "Global Variable not in module?!");
173173
GVSet.insert(CMGV);
174174
}
@@ -260,11 +260,11 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function *> &Funcs) {
260260

261261
// Convert list to set for fast lookup...
262262
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]);
265265
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");
268268
Functions.insert(CMF);
269269
}
270270

@@ -468,8 +468,8 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock *> &BBs) {
468468

469469
// Convert list to set for fast lookup...
470470
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]));
473473

474474
outs() << "Checking for crash with only these blocks:";
475475
unsigned NumPrint = Blocks.size();
@@ -765,9 +765,9 @@ bool ReduceCrashingInstructions::TestInsts(
765765

766766
// Convert list to set for fast lookup...
767767
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]));
771771
}
772772

773773
outs() << "Checking for crash with only " << Instructions.size();
@@ -776,9 +776,9 @@ bool ReduceCrashingInstructions::TestInsts(
776776
else
777777
outs() << " instructions: ";
778778

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)) {
782782
if (!Instructions.count(&Inst) && !Inst.isTerminator() &&
783783
!Inst.isEHPad() && !Inst.getType()->isTokenTy() &&
784784
!Inst.isSwiftError()) {
@@ -1105,9 +1105,8 @@ static Error ReduceInsts(BugDriver &BD, BugTester TestFn) {
11051105
E = BD.getProgram().end();
11061106
FI != E; ++FI)
11071107
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();
11111110
I != E; ++I, ++CurInstructionNum) {
11121111
if (InstructionsToSkipBeforeDeleting) {
11131112
--InstructionsToSkipBeforeDeleting;

0 commit comments

Comments
 (0)