[llvm] 852b11c - [bugpoint] Use range-based for loops (NFC) (#140438)
via llvm-commits
llvm-commits at lists.llvm.org
Sun May 18 07:35:45 PDT 2025
Author: Kazu Hirata
Date: 2025-05-18T07:35:42-07:00
New Revision: 852b11c75fb8f6132298b9a67c886b02ff9d387a
URL: https://github.com/llvm/llvm-project/commit/852b11c75fb8f6132298b9a67c886b02ff9d387a
DIFF: https://github.com/llvm/llvm-project/commit/852b11c75fb8f6132298b9a67c886b02ff9d387a.diff
LOG: [bugpoint] Use range-based for loops (NFC) (#140438)
Added:
Modified:
llvm/tools/bugpoint/CrashDebugger.cpp
Removed:
################################################################################
diff --git a/llvm/tools/bugpoint/CrashDebugger.cpp b/llvm/tools/bugpoint/CrashDebugger.cpp
index e2f7e104c58e3..fcac0144a706d 100644
--- a/llvm/tools/bugpoint/CrashDebugger.cpp
+++ b/llvm/tools/bugpoint/CrashDebugger.cpp
@@ -167,8 +167,8 @@ bool ReduceCrashingGlobalInitializers::TestGlobalVariables(
// Convert list to set for fast lookup...
std::set<GlobalVariable *> GVSet;
- for (unsigned i = 0, e = GVs.size(); i != e; ++i) {
- GlobalVariable *CMGV = cast<GlobalVariable>(VMap[GVs[i]]);
+ for (GlobalVariable *GV : GVs) {
+ GlobalVariable *CMGV = cast<GlobalVariable>(VMap[GV]);
assert(CMGV && "Global Variable not in module?!");
GVSet.insert(CMGV);
}
@@ -260,11 +260,11 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function *> &Funcs) {
// Convert list to set for fast lookup...
std::set<Function *> Functions;
- for (unsigned i = 0, e = Funcs.size(); i != e; ++i) {
- Function *CMF = cast<Function>(VMap[Funcs[i]]);
+ for (Function *Func : Funcs) {
+ Function *CMF = cast<Function>(VMap[Func]);
assert(CMF && "Function not in module?!");
- assert(CMF->getFunctionType() == Funcs[i]->getFunctionType() && "wrong ty");
- assert(CMF->getName() == Funcs[i]->getName() && "wrong name");
+ assert(CMF->getFunctionType() == Func->getFunctionType() && "wrong ty");
+ assert(CMF->getName() == Func->getName() && "wrong name");
Functions.insert(CMF);
}
@@ -468,8 +468,8 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock *> &BBs) {
// Convert list to set for fast lookup...
SmallPtrSet<BasicBlock *, 8> Blocks;
- for (unsigned i = 0, e = BBs.size(); i != e; ++i)
- Blocks.insert(cast<BasicBlock>(VMap[BBs[i]]));
+ for (const BasicBlock *BB : BBs)
+ Blocks.insert(cast<BasicBlock>(VMap[BB]));
outs() << "Checking for crash with only these blocks:";
unsigned NumPrint = Blocks.size();
@@ -765,9 +765,9 @@ bool ReduceCrashingInstructions::TestInsts(
// Convert list to set for fast lookup...
SmallPtrSet<Instruction *, 32> Instructions;
- for (unsigned i = 0, e = Insts.size(); i != e; ++i) {
- assert(!Insts[i]->isTerminator());
- Instructions.insert(cast<Instruction>(VMap[Insts[i]]));
+ for (const Instruction *Inst : Insts) {
+ assert(!Inst->isTerminator());
+ Instructions.insert(cast<Instruction>(VMap[Inst]));
}
outs() << "Checking for crash with only " << Instructions.size();
@@ -776,9 +776,9 @@ bool ReduceCrashingInstructions::TestInsts(
else
outs() << " instructions: ";
- for (Module::iterator MI = M->begin(), ME = M->end(); MI != ME; ++MI)
- for (Function::iterator FI = MI->begin(), FE = MI->end(); FI != FE; ++FI)
- for (Instruction &Inst : llvm::make_early_inc_range(*FI)) {
+ for (Function &F : *M)
+ for (BasicBlock &BB : F)
+ for (Instruction &Inst : llvm::make_early_inc_range(BB)) {
if (!Instructions.count(&Inst) && !Inst.isTerminator() &&
!Inst.isEHPad() && !Inst.getType()->isTokenTy() &&
!Inst.isSwiftError()) {
@@ -1105,9 +1105,8 @@ static Error ReduceInsts(BugDriver &BD, BugTester TestFn) {
E = BD.getProgram().end();
FI != E; ++FI)
if (!FI->isDeclaration())
- for (Function::const_iterator BI = FI->begin(), E = FI->end(); BI != E;
- ++BI)
- for (BasicBlock::const_iterator I = BI->begin(), E = --BI->end();
+ for (const BasicBlock &BI : *FI)
+ for (BasicBlock::const_iterator I = BI.begin(), E = --BI.end();
I != E; ++I, ++CurInstructionNum) {
if (InstructionsToSkipBeforeDeleting) {
--InstructionsToSkipBeforeDeleting;
More information about the llvm-commits
mailing list