[lld] [lld] Use range-based for loops (NFC) (PR #144251)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Jun 15 00:39:00 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-lld-wasm
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/144251.diff
4 Files Affected:
- (modified) lld/ELF/Arch/ARM.cpp (+3-3)
- (modified) lld/ELF/SyntheticSections.cpp (+3-4)
- (modified) lld/MachO/SyntheticSections.cpp (+1-3)
- (modified) lld/wasm/Driver.cpp (+3-3)
``````````diff
diff --git a/lld/ELF/Arch/ARM.cpp b/lld/ELF/Arch/ARM.cpp
index aa90fecc533e3..91a673f13d68e 100644
--- a/lld/ELF/Arch/ARM.cpp
+++ b/lld/ELF/Arch/ARM.cpp
@@ -1317,11 +1317,11 @@ void elf::processArmCmseSymbols(Ctx &ctx) {
// with its corresponding special symbol __acle_se_<sym>.
parallelForEach(ctx.objectFiles, [&](InputFile *file) {
MutableArrayRef<Symbol *> syms = file->getMutableSymbols();
- for (size_t i = 0, e = syms.size(); i != e; ++i) {
- StringRef symName = syms[i]->getName();
+ for (Symbol *&sym : syms) {
+ StringRef symName = sym->getName();
auto it = ctx.symtab->cmseSymMap.find(symName);
if (it != ctx.symtab->cmseSymMap.end())
- syms[i] = it->second.acleSeSym;
+ sym = it->second.acleSeSym;
}
});
}
diff --git a/lld/ELF/SyntheticSections.cpp b/lld/ELF/SyntheticSections.cpp
index 051e5cd04ef50..efec41a737b62 100644
--- a/lld/ELF/SyntheticSections.cpp
+++ b/lld/ELF/SyntheticSections.cpp
@@ -4026,10 +4026,9 @@ void MergeNoTailSection::finalizeContents() {
// So far, section pieces have offsets from beginning of shards, but
// we want offsets from beginning of the whole section. Fix them.
parallelForEach(sections, [&](MergeInputSection *sec) {
- for (size_t i = 0, e = sec->pieces.size(); i != e; ++i)
- if (sec->pieces[i].live)
- sec->pieces[i].outputOff +=
- shardOffsets[getShardId(sec->pieces[i].hash)];
+ for (SectionPiece &piece : sec->pieces)
+ if (piece.live)
+ piece.outputOff += shardOffsets[getShardId(piece.hash)];
});
}
diff --git a/lld/MachO/SyntheticSections.cpp b/lld/MachO/SyntheticSections.cpp
index 0b7f233042487..979a4ee6d8133 100644
--- a/lld/MachO/SyntheticSections.cpp
+++ b/lld/MachO/SyntheticSections.cpp
@@ -947,9 +947,7 @@ uint64_t ObjCStubsSection::getSize() const {
void ObjCStubsSection::writeTo(uint8_t *buf) const {
uint64_t stubOffset = 0;
- for (size_t i = 0, n = symbols.size(); i < n; ++i) {
- Defined *sym = symbols[i];
-
+ for (Defined *sym : symbols) {
auto methname = getMethname(sym);
InputSection *selRef = ObjCSelRefsHelper::getSelRef(methname);
assert(selRef != nullptr && "no selref for methname");
diff --git a/lld/wasm/Driver.cpp b/lld/wasm/Driver.cpp
index 2b1fb945f41c8..1c5d21c06f5af 100644
--- a/lld/wasm/Driver.cpp
+++ b/lld/wasm/Driver.cpp
@@ -1226,9 +1226,9 @@ static void wrapSymbols(ArrayRef<WrappedSymbol> wrapped) {
// Update pointers in input files.
parallelForEach(ctx.objectFiles, [&](InputFile *file) {
MutableArrayRef<Symbol *> syms = file->getMutableSymbols();
- for (size_t i = 0, e = syms.size(); i != e; ++i)
- if (Symbol *s = map.lookup(syms[i]))
- syms[i] = s;
+ for (Symbol *&sym : syms)
+ if (Symbol *s = map.lookup(sym))
+ sym = s;
});
// Update pointers in the symbol table.
``````````
</details>
https://github.com/llvm/llvm-project/pull/144251
More information about the llvm-commits
mailing list