Skip to content

[Transforms] Use range-based for loops (NFC) #98465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions llvm/lib/Transforms/ObjCARC/DependencyAnalysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,16 +220,13 @@ static bool findDependencies(DependenceKind Flavor, const Value *Arg,
BasicBlock::iterator StartBBBegin = LocalStartBB->begin();
for (;;) {
if (LocalStartPos == StartBBBegin) {
pred_iterator PI(LocalStartBB), PE(LocalStartBB, false);
if (PI == PE)
if (pred_empty(LocalStartBB))
// Return if we've reached the function entry.
return false;
// Add the predecessors to the worklist.
do {
BasicBlock *PredBB = *PI;
for (BasicBlock *PredBB : predecessors(LocalStartBB))
if (Visited.insert(PredBB).second)
Worklist.push_back(std::make_pair(PredBB, PredBB->end()));
} while (++PI != PE);
break;
}

Expand Down
8 changes: 2 additions & 6 deletions llvm/lib/Transforms/Scalar/NewGVN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2525,18 +2525,14 @@ void NewGVN::processOutgoingEdges(Instruction *TI, BasicBlock *B) {
BasicBlock *TargetBlock = Case.getCaseSuccessor();
updateReachableEdge(B, TargetBlock);
} else {
for (unsigned i = 0, e = SI->getNumSuccessors(); i != e; ++i) {
BasicBlock *TargetBlock = SI->getSuccessor(i);
for (BasicBlock *TargetBlock : successors(SI->getParent()))
updateReachableEdge(B, TargetBlock);
}
}
} else {
// Otherwise this is either unconditional, or a type we have no
// idea about. Just mark successors as reachable.
for (unsigned i = 0, e = TI->getNumSuccessors(); i != e; ++i) {
BasicBlock *TargetBlock = TI->getSuccessor(i);
for (BasicBlock *TargetBlock : successors(TI->getParent()))
updateReachableEdge(B, TargetBlock);
}

// This also may be a memory defining terminator, in which case, set it
// equivalent only to itself.
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/Reassociate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1399,8 +1399,8 @@ Value *ReassociatePass::OptimizeXor(Instruction *I,
// the "OpndPtrs" as well. For the similar reason, do not fuse this loop
// with the previous loop --- the iterator of the "Opnds" may be invalidated
// when new elements are added to the vector.
for (unsigned i = 0, e = Opnds.size(); i != e; ++i)
OpndPtrs.push_back(&Opnds[i]);
for (XorOpnd &Op : Opnds)
OpndPtrs.push_back(&Op);

// Step 2: Sort the Xor-Operands in a way such that the operands containing
// the same symbolic value cluster together. For instance, the input operand
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Utils/CloneModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,8 @@ std::unique_ptr<Module> llvm::CloneModule(
// And named metadata....
for (const NamedMDNode &NMD : M.named_metadata()) {
NamedMDNode *NewNMD = New->getOrInsertNamedMetadata(NMD.getName());
for (unsigned i = 0, e = NMD.getNumOperands(); i != e; ++i)
NewNMD->addOperand(MapMetadata(NMD.getOperand(i), VMap));
for (const MDNode *N : NMD.operands())
NewNMD->addOperand(MapMetadata(N, VMap));
}

return New;
Expand Down
Loading