[llvm] 4444b34 - [IR] Use range-based for loops (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 1 23:40:53 PST 2021
Author: Kazu Hirata
Date: 2021-03-01T23:40:33-08:00
New Revision: 4444b343d7e208e6e6f7ee885d380d90df1c231d
URL: https://github.com/llvm/llvm-project/commit/4444b343d7e208e6e6f7ee885d380d90df1c231d
DIFF: https://github.com/llvm/llvm-project/commit/4444b343d7e208e6e6f7ee885d380d90df1c231d.diff
LOG: [IR] Use range-based for loops (NFC)
Added:
Modified:
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/Core.cpp
llvm/lib/IR/ModuleSummaryIndex.cpp
llvm/lib/IR/Verifier.cpp
Removed:
################################################################################
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 43aba4efb6ea..3ae3bf430d2f 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -4373,9 +4373,8 @@ void AssemblyWriter::writeMDNode(unsigned Slot, const MDNode *Node) {
void AssemblyWriter::writeAllMDNodes() {
SmallVector<const MDNode *, 16> 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<MDNode>(I->first);
+ for (auto &I : llvm::make_range(Machine.mdn_begin(), Machine.mdn_end()))
+ Nodes[I.second] = cast<MDNode>(I.first);
for (unsigned i = 0, e = Nodes.size(); i != e; ++i) {
writeMDNode(i, Nodes[i]);
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 6631a4ac2248..7398a7efd8cd 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -3280,9 +3280,8 @@ unsigned LLVMGetNumHandlers(LLVMValueRef CatchSwitch) {
void LLVMGetHandlers(LLVMValueRef CatchSwitch, LLVMBasicBlockRef *Handlers) {
CatchSwitchInst *CSI = unwrap<CatchSwitchInst>(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/llvm/lib/IR/ModuleSummaryIndex.cpp b/llvm/lib/IR/ModuleSummaryIndex.cpp
index c2ded87c4947..f4ac6caf4f93 100644
--- a/llvm/lib/IR/ModuleSummaryIndex.cpp
+++ b/llvm/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<GlobalValueSummary> &Summary) {
- return Summary->setDSOLocal(false);
- });
+ for (const std::unique_ptr<GlobalValueSummary> &Summary :
+ P.second.SummaryList)
+ Summary->setDSOLocal(false);
}
setWithAttributePropagation();
setWithDSOLocalPropagation();
diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index c382600683e5..47bfbfb19524 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/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);
More information about the llvm-commits
mailing list