[llvm] b4bed1c - [IR] Use range-based for loops (NFC)
Kazu Hirata via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 28 10:59:55 PST 2021
Author: Kazu Hirata
Date: 2021-02-28T10:59:23-08:00
New Revision: b4bed1cb245b04ed6ed50b5d68d928e9e9f216f7
URL: https://github.com/llvm/llvm-project/commit/b4bed1cb245b04ed6ed50b5d68d928e9e9f216f7
DIFF: https://github.com/llvm/llvm-project/commit/b4bed1cb245b04ed6ed50b5d68d928e9e9f216f7.diff
LOG: [IR] Use range-based for loops (NFC)
Added:
Modified:
llvm/include/llvm/IR/LegacyPassManagers.h
llvm/lib/IR/AsmWriter.cpp
llvm/lib/IR/DebugInfo.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/IR/LegacyPassManagers.h b/llvm/include/llvm/IR/LegacyPassManagers.h
index f4fae184e428..0bcb408d4929 100644
--- a/llvm/include/llvm/IR/LegacyPassManagers.h
+++ b/llvm/include/llvm/IR/LegacyPassManagers.h
@@ -335,8 +335,8 @@ class PMDataManager {
/// Initialize available analysis information.
void initializeAnalysisInfo() {
AvailableAnalysis.clear();
- for (unsigned i = 0; i < PMT_Last; ++i)
- InheritedAnalysis[i] = nullptr;
+ for (auto &IA : InheritedAnalysis)
+ IA = nullptr;
}
// Return true if P preserves high level analysis used by other
@@ -392,9 +392,8 @@ class PMDataManager {
// Collect AvailableAnalysis from all the active Pass Managers.
void populateInheritedAnalysis(PMStack &PMS) {
unsigned Index = 0;
- for (PMStack::iterator I = PMS.begin(), E = PMS.end();
- I != E; ++I)
- InheritedAnalysis[Index++] = (*I)->getAvailableAnalysis();
+ for (PMDataManager *PMDM : PMS)
+ InheritedAnalysis[Index++] = PMDM->getAvailableAnalysis();
}
/// Set the initial size of the module if the user has specified that they
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 642ecc92e9bb..43aba4efb6ea 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -1088,9 +1088,8 @@ int SlotTracker::processIndex() {
// Start numbering the TypeIds after the GUIDs.
TypeIdNext = GUIDNext;
- for (auto TidIter = TheIndex->typeIds().begin();
- TidIter != TheIndex->typeIds().end(); TidIter++)
- CreateTypeIdSlot(TidIter->second.first);
+ for (const auto &TID : TheIndex->typeIds())
+ CreateTypeIdSlot(TID.second.first);
ST_DEBUG("end processIndex!\n");
return TypeIdNext;
@@ -4028,8 +4027,8 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
Out << ' ';
writeOperand(I.getOperand(0), true); Out << ", ";
writeOperand(I.getOperand(1), true);
- for (const unsigned *i = IVI->idx_begin(), *e = IVI->idx_end(); i != e; ++i)
- Out << ", " << *i;
+ for (unsigned i : IVI->indices())
+ Out << ", " << i;
} else if (const LandingPadInst *LPI = dyn_cast<LandingPadInst>(&I)) {
Out << ' ';
TypePrinter.print(I.getType(), Out);
@@ -4431,9 +4430,8 @@ void AssemblyWriter::writeAllAttributeGroups() {
std::vector<std::pair<AttributeSet, unsigned>> asVec;
asVec.resize(Machine.as_size());
- for (SlotTracker::as_iterator I = Machine.as_begin(), E = Machine.as_end();
- I != E; ++I)
- asVec[I->second] = *I;
+ for (auto &I : llvm::make_range(Machine.as_begin(), Machine.as_end()))
+ asVec[I.second] = I;
for (const auto &I : asVec)
Out << "attributes #" << I.second << " = { "
diff --git a/llvm/lib/IR/DebugInfo.cpp b/llvm/lib/IR/DebugInfo.cpp
index 3413447f72c0..fec98f5a36c0 100644
--- a/llvm/lib/IR/DebugInfo.cpp
+++ b/llvm/lib/IR/DebugInfo.cpp
@@ -353,16 +353,12 @@ bool llvm::stripDebugInfo(Function &F) {
bool llvm::StripDebugInfo(Module &M) {
bool Changed = false;
- for (Module::named_metadata_iterator NMI = M.named_metadata_begin(),
- NME = M.named_metadata_end(); NMI != NME;) {
- NamedMDNode *NMD = &*NMI;
- ++NMI;
-
+ for (NamedMDNode &NMD : llvm::make_early_inc_range(M.named_metadata())) {
// We're stripping debug info, and without them, coverage information
// doesn't quite make sense.
- if (NMD->getName().startswith("llvm.dbg.") ||
- NMD->getName() == "llvm.gcov") {
- NMD->eraseFromParent();
+ if (NMD.getName().startswith("llvm.dbg.") ||
+ NMD.getName() == "llvm.gcov") {
+ NMD.eraseFromParent();
Changed = true;
}
}
More information about the llvm-commits
mailing list