-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[MC] Use range-based for loops (NFC) #139354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kazutakahirata
merged 2 commits into
llvm:main
from
kazutakahirata:cleanup_001_tidy_modernize-loop-convert_llvm_MC
May 10, 2025
Merged
[MC] Use range-based for loops (NFC) #139354
kazutakahirata
merged 2 commits into
llvm:main
from
kazutakahirata:cleanup_001_tidy_modernize-loop-convert_llvm_MC
May 10, 2025
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-mc Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/139354.diff 4 Files Affected:
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index eaaa57408becf..73c3a3a00b5c6 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -809,8 +809,8 @@ void MCAssembler::writeSectionData(raw_ostream &OS,
getContext().reportError(SMLoc(), Sec->getVirtualSectionKind() +
" section '" + Sec->getName() +
"' cannot have fixups");
- for (unsigned i = 0, e = DF.getContents().size(); i != e; ++i)
- if (DF.getContents()[i]) {
+ for (char C : DF.getContents())
+ if (C) {
getContext().reportError(SMLoc(),
Sec->getVirtualSectionKind() +
" section '" + Sec->getName() +
diff --git a/llvm/lib/MC/MCContext.cpp b/llvm/lib/MC/MCContext.cpp
index 1a6f3b3c17ea0..38d7abd43d214 100644
--- a/llvm/lib/MC/MCContext.cpp
+++ b/llvm/lib/MC/MCContext.cpp
@@ -477,10 +477,10 @@ MCSymbolXCOFF *MCContext::createXCOFFSymbolImpl(const MCSymbolTableEntry *Name,
// Append the hex values of '_' and invalid characters with "_Renamed..";
// at the same time replace invalid characters with '_'.
- for (size_t I = 0; I < InvalidName.size(); ++I) {
- if (!MAI->isAcceptableChar(InvalidName[I]) || InvalidName[I] == '_') {
- raw_svector_ostream(ValidName).write_hex(InvalidName[I]);
- InvalidName[I] = '_';
+ for (char &I : InvalidName) {
+ if (!MAI->isAcceptableChar(I) || I == '_') {
+ raw_svector_ostream(ValidName).write_hex(I);
+ I = '_';
}
}
diff --git a/llvm/lib/MC/MCWasmStreamer.cpp b/llvm/lib/MC/MCWasmStreamer.cpp
index 117eae7e23b8e..cddd250cc0005 100644
--- a/llvm/lib/MC/MCWasmStreamer.cpp
+++ b/llvm/lib/MC/MCWasmStreamer.cpp
@@ -179,9 +179,9 @@ void MCWasmStreamer::emitInstToData(const MCInst &Inst,
MCDataFragment *DF = getOrCreateDataFragment();
// Add the fixups and data.
- for (unsigned I = 0, E = Fixups.size(); I != E; ++I) {
- Fixups[I].setOffset(Fixups[I].getOffset() + DF->getContents().size());
- DF->getFixups().push_back(Fixups[I]);
+ for (MCFixup &Fixup : Fixups) {
+ Fixup.setOffset(Fixup.getOffset() + DF->getContents().size());
+ DF->getFixups().push_back(Fixup);
}
DF->setHasInstructions(STI);
DF->appendContents(Code);
diff --git a/llvm/lib/MC/MCWinCOFFStreamer.cpp b/llvm/lib/MC/MCWinCOFFStreamer.cpp
index 419ea6da426fd..e03f7b5b6d418 100644
--- a/llvm/lib/MC/MCWinCOFFStreamer.cpp
+++ b/llvm/lib/MC/MCWinCOFFStreamer.cpp
@@ -145,9 +145,9 @@ void MCWinCOFFStreamer::emitInstToData(const MCInst &Inst,
getAssembler().getEmitter().encodeInstruction(Inst, Code, Fixups, STI);
// Add the fixups and data.
- for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
- Fixups[i].setOffset(Fixups[i].getOffset() + DF->getContents().size());
- DF->getFixups().push_back(Fixups[i]);
+ for (MCFixup &Fixup : Fixups) {
+ Fixup.setOffset(Fixup.getOffset() + DF->getContents().size());
+ DF->getFixups().push_back(Fixup);
}
DF->setHasInstructions(STI);
DF->appendContents(Code);
|
shiltian
reviewed
May 10, 2025
shiltian
approved these changes
May 10, 2025
shiltian
approved these changes
May 10, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.