From 16b2ace0abb8e15e0b7aa10b01893441d9bdbc7f Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Wed, 28 Sep 2016 17:31:17 +0000 Subject: [PATCH] Rewrite loops to use range-based for. (NFC) llvm-svn: 282608 --- llvm/lib/CodeGen/LexicalScopes.cpp | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/llvm/lib/CodeGen/LexicalScopes.cpp b/llvm/lib/CodeGen/LexicalScopes.cpp index b810176..834ed5f 100644 --- a/llvm/lib/CodeGen/LexicalScopes.cpp +++ b/llvm/lib/CodeGen/LexicalScopes.cpp @@ -222,17 +222,13 @@ void LexicalScopes::constructScopeNest(LexicalScope *Scope) { LexicalScope *WS = WorkStack.back(); const SmallVectorImpl &Children = WS->getChildren(); bool visitedChildren = false; - for (SmallVectorImpl::const_iterator SI = Children.begin(), - SE = Children.end(); - SI != SE; ++SI) { - LexicalScope *ChildScope = *SI; + for (auto &ChildScope : Children) if (!ChildScope->getDFSOut()) { WorkStack.push_back(ChildScope); visitedChildren = true; ChildScope->setDFSIn(++Counter); break; } - } if (!visitedChildren) { WorkStack.pop_back(); WS->setDFSOut(++Counter); @@ -247,10 +243,7 @@ void LexicalScopes::assignInstructionRanges( DenseMap &MI2ScopeMap) { LexicalScope *PrevLexicalScope = nullptr; - for (SmallVectorImpl::const_iterator RI = MIRanges.begin(), - RE = MIRanges.end(); - RI != RE; ++RI) { - const InsnRange &R = *RI; + for (const auto &R : MIRanges) { LexicalScope *S = MI2ScopeMap.lookup(R.first); assert(S && "Lost LexicalScope for a machine instruction!"); if (PrevLexicalScope && !PrevLexicalScope->dominates(S)) @@ -281,12 +274,8 @@ void LexicalScopes::getMachineBasicBlocks( } SmallVectorImpl &InsnRanges = Scope->getRanges(); - for (SmallVectorImpl::iterator I = InsnRanges.begin(), - E = InsnRanges.end(); - I != E; ++I) { - InsnRange &R = *I; + for (auto &R : InsnRanges) MBBs.insert(R.first->getParent()); - } } /// dominates - Return true if DebugLoc's lexical scope dominates at least one @@ -301,9 +290,8 @@ bool LexicalScopes::dominates(const DILocation *DL, MachineBasicBlock *MBB) { return true; bool Result = false; - for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end(); I != E; - ++I) { - if (const DILocation *IDL = I->getDebugLoc()) + for (auto &I : *MBB) { + if (const DILocation *IDL = I.getDebugLoc()) if (LexicalScope *IScope = getOrCreateLexicalScope(IDL)) if (Scope->dominates(IScope)) return true; -- 2.7.4