Skip to content

Commit d78eec8

Browse files
[lld] Use range-based for loops (NFC) (#144251)
1 parent fef5df9 commit d78eec8

File tree

4 files changed

+10
-13
lines changed

4 files changed

+10
-13
lines changed

lld/ELF/Arch/ARM.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,11 +1317,11 @@ void elf::processArmCmseSymbols(Ctx &ctx) {
13171317
// with its corresponding special symbol __acle_se_<sym>.
13181318
parallelForEach(ctx.objectFiles, [&](InputFile *file) {
13191319
MutableArrayRef<Symbol *> syms = file->getMutableSymbols();
1320-
for (size_t i = 0, e = syms.size(); i != e; ++i) {
1321-
StringRef symName = syms[i]->getName();
1320+
for (Symbol *&sym : syms) {
1321+
StringRef symName = sym->getName();
13221322
auto it = ctx.symtab->cmseSymMap.find(symName);
13231323
if (it != ctx.symtab->cmseSymMap.end())
1324-
syms[i] = it->second.acleSeSym;
1324+
sym = it->second.acleSeSym;
13251325
}
13261326
});
13271327
}

lld/ELF/SyntheticSections.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4026,10 +4026,9 @@ void MergeNoTailSection::finalizeContents() {
40264026
// So far, section pieces have offsets from beginning of shards, but
40274027
// we want offsets from beginning of the whole section. Fix them.
40284028
parallelForEach(sections, [&](MergeInputSection *sec) {
4029-
for (size_t i = 0, e = sec->pieces.size(); i != e; ++i)
4030-
if (sec->pieces[i].live)
4031-
sec->pieces[i].outputOff +=
4032-
shardOffsets[getShardId(sec->pieces[i].hash)];
4029+
for (SectionPiece &piece : sec->pieces)
4030+
if (piece.live)
4031+
piece.outputOff += shardOffsets[getShardId(piece.hash)];
40334032
});
40344033
}
40354034

lld/MachO/SyntheticSections.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -947,9 +947,7 @@ uint64_t ObjCStubsSection::getSize() const {
947947

948948
void ObjCStubsSection::writeTo(uint8_t *buf) const {
949949
uint64_t stubOffset = 0;
950-
for (size_t i = 0, n = symbols.size(); i < n; ++i) {
951-
Defined *sym = symbols[i];
952-
950+
for (Defined *sym : symbols) {
953951
auto methname = getMethname(sym);
954952
InputSection *selRef = ObjCSelRefsHelper::getSelRef(methname);
955953
assert(selRef != nullptr && "no selref for methname");

lld/wasm/Driver.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,9 +1226,9 @@ static void wrapSymbols(ArrayRef<WrappedSymbol> wrapped) {
12261226
// Update pointers in input files.
12271227
parallelForEach(ctx.objectFiles, [&](InputFile *file) {
12281228
MutableArrayRef<Symbol *> syms = file->getMutableSymbols();
1229-
for (size_t i = 0, e = syms.size(); i != e; ++i)
1230-
if (Symbol *s = map.lookup(syms[i]))
1231-
syms[i] = s;
1229+
for (Symbol *&sym : syms)
1230+
if (Symbol *s = map.lookup(sym))
1231+
sym = s;
12321232
});
12331233

12341234
// Update pointers in the symbol table.

0 commit comments

Comments
 (0)