Skip to content

Commit b4bed1c

Browse files
[IR] Use range-based for loops (NFC)
1 parent 87360d6 commit b4bed1c

File tree

3 files changed

+14
-21
lines changed

3 files changed

+14
-21
lines changed

llvm/include/llvm/IR/LegacyPassManagers.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,8 @@ class PMDataManager {
335335
/// Initialize available analysis information.
336336
void initializeAnalysisInfo() {
337337
AvailableAnalysis.clear();
338-
for (unsigned i = 0; i < PMT_Last; ++i)
339-
InheritedAnalysis[i] = nullptr;
338+
for (auto &IA : InheritedAnalysis)
339+
IA = nullptr;
340340
}
341341

342342
// Return true if P preserves high level analysis used by other
@@ -392,9 +392,8 @@ class PMDataManager {
392392
// Collect AvailableAnalysis from all the active Pass Managers.
393393
void populateInheritedAnalysis(PMStack &PMS) {
394394
unsigned Index = 0;
395-
for (PMStack::iterator I = PMS.begin(), E = PMS.end();
396-
I != E; ++I)
397-
InheritedAnalysis[Index++] = (*I)->getAvailableAnalysis();
395+
for (PMDataManager *PMDM : PMS)
396+
InheritedAnalysis[Index++] = PMDM->getAvailableAnalysis();
398397
}
399398

400399
/// Set the initial size of the module if the user has specified that they

llvm/lib/IR/AsmWriter.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,9 +1088,8 @@ int SlotTracker::processIndex() {
10881088

10891089
// Start numbering the TypeIds after the GUIDs.
10901090
TypeIdNext = GUIDNext;
1091-
for (auto TidIter = TheIndex->typeIds().begin();
1092-
TidIter != TheIndex->typeIds().end(); TidIter++)
1093-
CreateTypeIdSlot(TidIter->second.first);
1091+
for (const auto &TID : TheIndex->typeIds())
1092+
CreateTypeIdSlot(TID.second.first);
10941093

10951094
ST_DEBUG("end processIndex!\n");
10961095
return TypeIdNext;
@@ -4028,8 +4027,8 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
40284027
Out << ' ';
40294028
writeOperand(I.getOperand(0), true); Out << ", ";
40304029
writeOperand(I.getOperand(1), true);
4031-
for (const unsigned *i = IVI->idx_begin(), *e = IVI->idx_end(); i != e; ++i)
4032-
Out << ", " << *i;
4030+
for (unsigned i : IVI->indices())
4031+
Out << ", " << i;
40334032
} else if (const LandingPadInst *LPI = dyn_cast<LandingPadInst>(&I)) {
40344033
Out << ' ';
40354034
TypePrinter.print(I.getType(), Out);
@@ -4431,9 +4430,8 @@ void AssemblyWriter::writeAllAttributeGroups() {
44314430
std::vector<std::pair<AttributeSet, unsigned>> asVec;
44324431
asVec.resize(Machine.as_size());
44334432

4434-
for (SlotTracker::as_iterator I = Machine.as_begin(), E = Machine.as_end();
4435-
I != E; ++I)
4436-
asVec[I->second] = *I;
4433+
for (auto &I : llvm::make_range(Machine.as_begin(), Machine.as_end()))
4434+
asVec[I.second] = I;
44374435

44384436
for (const auto &I : asVec)
44394437
Out << "attributes #" << I.second << " = { "

llvm/lib/IR/DebugInfo.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -353,16 +353,12 @@ bool llvm::stripDebugInfo(Function &F) {
353353
bool llvm::StripDebugInfo(Module &M) {
354354
bool Changed = false;
355355

356-
for (Module::named_metadata_iterator NMI = M.named_metadata_begin(),
357-
NME = M.named_metadata_end(); NMI != NME;) {
358-
NamedMDNode *NMD = &*NMI;
359-
++NMI;
360-
356+
for (NamedMDNode &NMD : llvm::make_early_inc_range(M.named_metadata())) {
361357
// We're stripping debug info, and without them, coverage information
362358
// doesn't quite make sense.
363-
if (NMD->getName().startswith("llvm.dbg.") ||
364-
NMD->getName() == "llvm.gcov") {
365-
NMD->eraseFromParent();
359+
if (NMD.getName().startswith("llvm.dbg.") ||
360+
NMD.getName() == "llvm.gcov") {
361+
NMD.eraseFromParent();
366362
Changed = true;
367363
}
368364
}

0 commit comments

Comments
 (0)