Skip to content

Commit 6bf948c

Browse files
[MC] Use range-based for loops (NFC) (#139354)
1 parent abedb5e commit 6bf948c

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

llvm/lib/MC/MCAssembler.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -809,8 +809,8 @@ void MCAssembler::writeSectionData(raw_ostream &OS,
809809
getContext().reportError(SMLoc(), Sec->getVirtualSectionKind() +
810810
" section '" + Sec->getName() +
811811
"' cannot have fixups");
812-
for (unsigned i = 0, e = DF.getContents().size(); i != e; ++i)
813-
if (DF.getContents()[i]) {
812+
for (char C : DF.getContents())
813+
if (C) {
814814
getContext().reportError(SMLoc(),
815815
Sec->getVirtualSectionKind() +
816816
" section '" + Sec->getName() +

llvm/lib/MC/MCContext.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,10 +477,10 @@ MCSymbolXCOFF *MCContext::createXCOFFSymbolImpl(const MCSymbolTableEntry *Name,
477477

478478
// Append the hex values of '_' and invalid characters with "_Renamed..";
479479
// at the same time replace invalid characters with '_'.
480-
for (size_t I = 0; I < InvalidName.size(); ++I) {
481-
if (!MAI->isAcceptableChar(InvalidName[I]) || InvalidName[I] == '_') {
482-
raw_svector_ostream(ValidName).write_hex(InvalidName[I]);
483-
InvalidName[I] = '_';
480+
for (char &C : InvalidName) {
481+
if (!MAI->isAcceptableChar(C) || C == '_') {
482+
raw_svector_ostream(ValidName).write_hex(C);
483+
C = '_';
484484
}
485485
}
486486

llvm/lib/MC/MCWasmStreamer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,9 @@ void MCWasmStreamer::emitInstToData(const MCInst &Inst,
179179
MCDataFragment *DF = getOrCreateDataFragment();
180180

181181
// Add the fixups and data.
182-
for (unsigned I = 0, E = Fixups.size(); I != E; ++I) {
183-
Fixups[I].setOffset(Fixups[I].getOffset() + DF->getContents().size());
184-
DF->getFixups().push_back(Fixups[I]);
182+
for (MCFixup &Fixup : Fixups) {
183+
Fixup.setOffset(Fixup.getOffset() + DF->getContents().size());
184+
DF->getFixups().push_back(Fixup);
185185
}
186186
DF->setHasInstructions(STI);
187187
DF->appendContents(Code);

llvm/lib/MC/MCWinCOFFStreamer.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,9 @@ void MCWinCOFFStreamer::emitInstToData(const MCInst &Inst,
145145
getAssembler().getEmitter().encodeInstruction(Inst, Code, Fixups, STI);
146146

147147
// Add the fixups and data.
148-
for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
149-
Fixups[i].setOffset(Fixups[i].getOffset() + DF->getContents().size());
150-
DF->getFixups().push_back(Fixups[i]);
148+
for (MCFixup &Fixup : Fixups) {
149+
Fixup.setOffset(Fixup.getOffset() + DF->getContents().size());
150+
DF->getFixups().push_back(Fixup);
151151
}
152152
DF->setHasInstructions(STI);
153153
DF->appendContents(Code);

0 commit comments

Comments
 (0)