diff --git a/lib/IR/AsmWriter.cpp b/lib/IR/AsmWriter.cpp index 43aba4efb6e..3ae3bf430d2 100644 --- a/lib/IR/AsmWriter.cpp +++ b/lib/IR/AsmWriter.cpp @@ -4373,9 +4373,8 @@ void AssemblyWriter::writeMDNode(unsigned Slot, const MDNode *Node) { void AssemblyWriter::writeAllMDNodes() { SmallVector Nodes; Nodes.resize(Machine.mdn_size()); - for (SlotTracker::mdn_iterator I = Machine.mdn_begin(), E = Machine.mdn_end(); - I != E; ++I) - Nodes[I->second] = cast(I->first); + for (auto &I : llvm::make_range(Machine.mdn_begin(), Machine.mdn_end())) + Nodes[I.second] = cast(I.first); for (unsigned i = 0, e = Nodes.size(); i != e; ++i) { writeMDNode(i, Nodes[i]); diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp index 6631a4ac224..7398a7efd8c 100644 --- a/lib/IR/Core.cpp +++ b/lib/IR/Core.cpp @@ -3280,9 +3280,8 @@ unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch) { void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers) { CatchSwitchInst *CSI = unwrap(CatchSwitch); - for (CatchSwitchInst::handler_iterator I = CSI->handler_begin(), - E = CSI->handler_end(); I != E; ++I) - *Handlers++ = wrap(*I); + for (const BasicBlock *H : CSI->handlers()) + *Handlers++ = wrap(H); } LLVMValueRef LLVMGetParentCatchSwitch(LLVMValueRef CatchPad) { diff --git a/lib/IR/ModuleSummaryIndex.cpp b/lib/IR/ModuleSummaryIndex.cpp index c2ded87c494..f4ac6caf4f9 100644 --- a/lib/IR/ModuleSummaryIndex.cpp +++ b/lib/IR/ModuleSummaryIndex.cpp @@ -292,10 +292,9 @@ void ModuleSummaryIndex::propagateAttributes( if (!IsDSOLocal) // Mark the flag in all summaries false so that we can do quick check // without going through the whole list. - llvm::for_each(P.second.SummaryList, - [](const std::unique_ptr &Summary) { - return Summary->setDSOLocal(false); - }); + for (const std::unique_ptr &Summary : + P.second.SummaryList) + Summary->setDSOLocal(false); } setWithAttributePropagation(); setWithDSOLocalPropagation(); diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index c382600683e..47bfbfb1952 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -3671,10 +3671,9 @@ void Verifier::visitStoreInst(StoreInst &SI) { /// Check that SwiftErrorVal is used as a swifterror argument in CS. void Verifier::verifySwiftErrorCall(CallBase &Call, const Value *SwiftErrorVal) { - unsigned Idx = 0; - for (auto I = Call.arg_begin(), E = Call.arg_end(); I != E; ++I, ++Idx) { - if (*I == SwiftErrorVal) { - Assert(Call.paramHasAttr(Idx, Attribute::SwiftError), + for (const auto &I : llvm::enumerate(Call.args())) { + if (I.value() == SwiftErrorVal) { + Assert(Call.paramHasAttr(I.index(), Attribute::SwiftError), "swifterror value when used in a callsite should be marked " "with swifterror attribute", SwiftErrorVal, Call);