Skip to content

Commit 4444b34

Browse files
committedMar 2, 2021
[IR] Use range-based for loops (NFC)
1 parent 3a80088 commit 4444b34

File tree

4 files changed

+10
-14
lines changed

4 files changed

+10
-14
lines changed
 

‎llvm/lib/IR/AsmWriter.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -4373,9 +4373,8 @@ void AssemblyWriter::writeMDNode(unsigned Slot, const MDNode *Node) {
43734373
void AssemblyWriter::writeAllMDNodes() {
43744374
SmallVector<const MDNode *, 16> Nodes;
43754375
Nodes.resize(Machine.mdn_size());
4376-
for (SlotTracker::mdn_iterator I = Machine.mdn_begin(), E = Machine.mdn_end();
4377-
I != E; ++I)
4378-
Nodes[I->second] = cast<MDNode>(I->first);
4376+
for (auto &I : llvm::make_range(Machine.mdn_begin(), Machine.mdn_end()))
4377+
Nodes[I.second] = cast<MDNode>(I.first);
43794378

43804379
for (unsigned i = 0, e = Nodes.size(); i != e; ++i) {
43814380
writeMDNode(i, Nodes[i]);

‎llvm/lib/IR/Core.cpp

+2-3
Original file line numberDiff line numberDiff line change
@@ -3280,9 +3280,8 @@ unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch) {
32803280

32813281
void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers) {
32823282
CatchSwitchInst *CSI = unwrap<CatchSwitchInst>(CatchSwitch);
3283-
for (CatchSwitchInst::handler_iterator I = CSI->handler_begin(),
3284-
E = CSI->handler_end(); I != E; ++I)
3285-
*Handlers++ = wrap(*I);
3283+
for (const BasicBlock *H : CSI->handlers())
3284+
*Handlers++ = wrap(H);
32863285
}
32873286

32883287
LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad) {

‎llvm/lib/IR/ModuleSummaryIndex.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,9 @@ void ModuleSummaryIndex::propagateAttributes(
292292
if (!IsDSOLocal)
293293
// Mark the flag in all summaries false so that we can do quick check
294294
// without going through the whole list.
295-
llvm::for_each(P.second.SummaryList,
296-
[](const std::unique_ptr<GlobalValueSummary> &Summary) {
297-
return Summary->setDSOLocal(false);
298-
});
295+
for (const std::unique_ptr<GlobalValueSummary> &Summary :
296+
P.second.SummaryList)
297+
Summary->setDSOLocal(false);
299298
}
300299
setWithAttributePropagation();
301300
setWithDSOLocalPropagation();

‎llvm/lib/IR/Verifier.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -3671,10 +3671,9 @@ void Verifier::visitStoreInst(StoreInst &SI) {
36713671
/// Check that SwiftErrorVal is used as a swifterror argument in CS.
36723672
void Verifier::verifySwiftErrorCall(CallBase &Call,
36733673
const Value *SwiftErrorVal) {
3674-
unsigned Idx = 0;
3675-
for (auto I = Call.arg_begin(), E = Call.arg_end(); I != E; ++I, ++Idx) {
3676-
if (*I == SwiftErrorVal) {
3677-
Assert(Call.paramHasAttr(Idx, Attribute::SwiftError),
3674+
for (const auto &I : llvm::enumerate(Call.args())) {
3675+
if (I.value() == SwiftErrorVal) {
3676+
Assert(Call.paramHasAttr(I.index(), Attribute::SwiftError),
36783677
"swifterror value when used in a callsite should be marked "
36793678
"with swifterror attribute",
36803679
SwiftErrorVal, Call);

0 commit comments

Comments
 (0)
Please sign in to comment.