[llvm] r282608 - Rewrite loops to use range-based for. (NFC)
Adrian Prantl via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 28 10:31:18 PDT 2016
Author: adrian
Date: Wed Sep 28 12:31:17 2016
New Revision: 282608
URL: http://llvm.org/viewvc/llvm-project?rev=282608&view=rev
Log:
Rewrite loops to use range-based for. (NFC)
Modified:
llvm/trunk/lib/CodeGen/LexicalScopes.cpp
Modified: llvm/trunk/lib/CodeGen/LexicalScopes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LexicalScopes.cpp?rev=282608&r1=282607&r2=282608&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LexicalScopes.cpp (original)
+++ llvm/trunk/lib/CodeGen/LexicalScopes.cpp Wed Sep 28 12:31:17 2016
@@ -222,17 +222,13 @@ void LexicalScopes::constructScopeNest(L
LexicalScope *WS = WorkStack.back();
const SmallVectorImpl<LexicalScope *> &Children = WS->getChildren();
bool visitedChildren = false;
- for (SmallVectorImpl<LexicalScope *>::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::assignInstructionRan
DenseMap<const MachineInstr *, LexicalScope *> &MI2ScopeMap) {
LexicalScope *PrevLexicalScope = nullptr;
- for (SmallVectorImpl<InsnRange>::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::getMachineBasicBlock
}
SmallVectorImpl<InsnRange> &InsnRanges = Scope->getRanges();
- for (SmallVectorImpl<InsnRange>::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 DILo
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;
More information about the llvm-commits
mailing list