Skip to content

Commit 16b2ace

Browse files
committed
Rewrite loops to use range-based for. (NFC)
llvm-svn: 282608
1 parent 3e12115 commit 16b2ace

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

llvm/lib/CodeGen/LexicalScopes.cpp

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -222,17 +222,13 @@ void LexicalScopes::constructScopeNest(LexicalScope *Scope) {
222222
LexicalScope *WS = WorkStack.back();
223223
const SmallVectorImpl<LexicalScope *> &Children = WS->getChildren();
224224
bool visitedChildren = false;
225-
for (SmallVectorImpl<LexicalScope *>::const_iterator SI = Children.begin(),
226-
SE = Children.end();
227-
SI != SE; ++SI) {
228-
LexicalScope *ChildScope = *SI;
225+
for (auto &ChildScope : Children)
229226
if (!ChildScope->getDFSOut()) {
230227
WorkStack.push_back(ChildScope);
231228
visitedChildren = true;
232229
ChildScope->setDFSIn(++Counter);
233230
break;
234231
}
235-
}
236232
if (!visitedChildren) {
237233
WorkStack.pop_back();
238234
WS->setDFSOut(++Counter);
@@ -247,10 +243,7 @@ void LexicalScopes::assignInstructionRanges(
247243
DenseMap<const MachineInstr *, LexicalScope *> &MI2ScopeMap) {
248244

249245
LexicalScope *PrevLexicalScope = nullptr;
250-
for (SmallVectorImpl<InsnRange>::const_iterator RI = MIRanges.begin(),
251-
RE = MIRanges.end();
252-
RI != RE; ++RI) {
253-
const InsnRange &R = *RI;
246+
for (const auto &R : MIRanges) {
254247
LexicalScope *S = MI2ScopeMap.lookup(R.first);
255248
assert(S && "Lost LexicalScope for a machine instruction!");
256249
if (PrevLexicalScope && !PrevLexicalScope->dominates(S))
@@ -281,12 +274,8 @@ void LexicalScopes::getMachineBasicBlocks(
281274
}
282275

283276
SmallVectorImpl<InsnRange> &InsnRanges = Scope->getRanges();
284-
for (SmallVectorImpl<InsnRange>::iterator I = InsnRanges.begin(),
285-
E = InsnRanges.end();
286-
I != E; ++I) {
287-
InsnRange &R = *I;
277+
for (auto &R : InsnRanges)
288278
MBBs.insert(R.first->getParent());
289-
}
290279
}
291280

292281
/// dominates - Return true if DebugLoc's lexical scope dominates at least one
@@ -301,9 +290,8 @@ bool LexicalScopes::dominates(const DILocation *DL, MachineBasicBlock *MBB) {
301290
return true;
302291

303292
bool Result = false;
304-
for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); I != E;
305-
++I) {
306-
if (const DILocation *IDL = I->getDebugLoc())
293+
for (auto &I : *MBB) {
294+
if (const DILocation *IDL = I.getDebugLoc())
307295
if (LexicalScope *IScope = getOrCreateLexicalScope(IDL))
308296
if (Scope->dominates(IScope))
309297
return true;

0 commit comments

Comments
 (0)