<p dir="ltr">Didn't the I at the end of all these names stand for "iterator"? Should that be removed in patches like this?</p>
<div class="gmail_quote">On Apr 28, 2014 6:08 AM, "Aaron Ballman" <<a href="mailto:aaron@aaronballman.com">aaron@aaronballman.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: aaronballman<br>
Date: Mon Apr 28 08:01:32 2014<br>
New Revision: 207416<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=207416&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=207416&view=rev</a><br>
Log:<br>
[C++11] Converting to range-based for loops. No functional changes intended.<br>
<br>
Modified:<br>
cfe/trunk/lib/Analysis/Consumed.cpp<br>
<br>
Modified: cfe/trunk/lib/Analysis/Consumed.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Consumed.cpp?rev=207416&r1=207415&r2=207416&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/Consumed.cpp?rev=207416&r1=207415&r2=207416&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Analysis/Consumed.cpp (original)<br>
+++ cfe/trunk/lib/Analysis/Consumed.cpp Mon Apr 28 08:01:32 2014<br>
@@ -57,11 +57,9 @@ ConsumedWarningsHandlerBase::~ConsumedWa<br>
static SourceLocation getFirstStmtLoc(const CFGBlock *Block) {<br>
// Find the source location of the first statement in the block, if the block<br>
// is not empty.<br>
- for (CFGBlock::const_iterator BI = Block->begin(), BE = Block->end();<br>
- BI != BE; ++BI) {<br>
- if (Optional<CFGStmt> CS = BI->getAs<CFGStmt>())<br>
+ for (const auto &BI : *Block)<br>
+ if (Optional<CFGStmt> CS = BI.getAs<CFGStmt>())<br>
return CS->getStmt()->getLocStart();<br>
- }<br>
<br>
// Block is empty.<br>
// If we have one successor, return the first statement in that block<br>
@@ -1144,21 +1142,19 @@ bool ConsumedBlockInfo::isBackEdgeTarget<br>
void ConsumedStateMap::checkParamsForReturnTypestate(SourceLocation BlameLoc,<br>
ConsumedWarningsHandlerBase &WarningsHandler) const {<br>
<br>
- for (VarMapType::const_iterator DMI = VarMap.begin(), DME = VarMap.end();<br>
- DMI != DME; ++DMI) {<br>
-<br>
- if (isa<ParmVarDecl>(DMI->first)) {<br>
- const ParmVarDecl *Param = cast<ParmVarDecl>(DMI->first);<br>
+ for (const auto &DMI : VarMap) {<br>
+ if (isa<ParmVarDecl>(DMI.first)) {<br>
+ const ParmVarDecl *Param = cast<ParmVarDecl>(DMI.first);<br>
const ReturnTypestateAttr *RTA = Param->getAttr<ReturnTypestateAttr>();<br>
<br>
if (!RTA)<br>
continue;<br>
<br>
ConsumedState ExpectedState = mapReturnTypestateAttrState(RTA);<br>
- if (DMI->second != ExpectedState)<br>
+ if (DMI.second != ExpectedState)<br>
WarningsHandler.warnParamReturnTypestateMismatch(BlameLoc,<br>
Param->getNameAsString(), stateToString(ExpectedState),<br>
- stateToString(DMI->second));<br>
+ stateToString(DMI.second));<br>
}<br>
}<br>
}<br>
@@ -1194,16 +1190,14 @@ void ConsumedStateMap::intersect(const C<br>
return;<br>
}<br>
<br>
- for (VarMapType::const_iterator DMI = Other->VarMap.begin(),<br>
- DME = Other->VarMap.end(); DMI != DME; ++DMI) {<br>
-<br>
- LocalState = this->getState(DMI->first);<br>
+ for (const auto &DMI : Other->VarMap) {<br>
+ LocalState = this->getState(DMI.first);<br>
<br>
if (LocalState == CS_None)<br>
continue;<br>
<br>
- if (LocalState != DMI->second)<br>
- VarMap[DMI->first] = CS_Unknown;<br>
+ if (LocalState != DMI.second)<br>
+ VarMap[DMI.first] = CS_Unknown;<br>
}<br>
}<br>
<br>
@@ -1214,18 +1208,16 @@ void ConsumedStateMap::intersectAtLoopHe<br>
ConsumedState LocalState;<br>
SourceLocation BlameLoc = getLastStmtLoc(LoopBack);<br>
<br>
- for (VarMapType::const_iterator DMI = LoopBackStates->VarMap.begin(),<br>
- DME = LoopBackStates->VarMap.end(); DMI != DME; ++DMI) {<br>
-<br>
- LocalState = this->getState(DMI->first);<br>
+ for (const auto &DMI : LoopBackStates->VarMap) {<br>
+ LocalState = this->getState(DMI.first);<br>
<br>
if (LocalState == CS_None)<br>
continue;<br>
<br>
- if (LocalState != DMI->second) {<br>
- VarMap[DMI->first] = CS_Unknown;<br>
- WarningsHandler.warnLoopStateMismatch(<br>
- BlameLoc, DMI->first->getNameAsString());<br>
+ if (LocalState != DMI.second) {<br>
+ VarMap[DMI.first] = CS_Unknown;<br>
+ WarningsHandler.warnLoopStateMismatch(BlameLoc,<br>
+ DMI.first->getNameAsString());<br>
}<br>
}<br>
}<br>
@@ -1250,13 +1242,9 @@ void ConsumedStateMap::remove(const VarD<br>
}<br>
<br>
bool ConsumedStateMap::operator!=(const ConsumedStateMap *Other) const {<br>
- for (VarMapType::const_iterator DMI = Other->VarMap.begin(),<br>
- DME = Other->VarMap.end(); DMI != DME; ++DMI) {<br>
-<br>
- if (this->getState(DMI->first) != DMI->second)<br>
- return true;<br>
- }<br>
-<br>
+ for (const auto &DMI : Other->VarMap)<br>
+ if (this->getState(DMI.first) != DMI.second)<br>
+ return true;<br>
return false;<br>
}<br>
<br>
@@ -1396,16 +1384,11 @@ void ConsumedAnalyzer::run(AnalysisDeclC<br>
ConsumedStmtVisitor Visitor(AC, *this, CurrStates);<br>
<br>
// Add all trackable parameters to the state map.<br>
- for (auto PI : D->params()) {<br>
+ for (const auto *PI : D->params())<br>
Visitor.VisitParmVarDecl(PI);<br>
- }<br>
<br>
// Visit all of the function's basic blocks.<br>
- for (PostOrderCFGView::iterator I = SortedGraph->begin(),<br>
- E = SortedGraph->end(); I != E; ++I) {<br>
-<br>
- const CFGBlock *CurrBlock = *I;<br>
-<br>
+ for (const auto *CurrBlock : *SortedGraph) {<br>
if (CurrStates == NULL)<br>
CurrStates = BlockInfo.getInfo(CurrBlock);<br>
<br>
@@ -1421,16 +1404,14 @@ void ConsumedAnalyzer::run(AnalysisDeclC<br>
Visitor.reset(CurrStates);<br>
<br>
// Visit all of the basic block's statements.<br>
- for (CFGBlock::const_iterator BI = CurrBlock->begin(),<br>
- BE = CurrBlock->end(); BI != BE; ++BI) {<br>
-<br>
- switch (BI->getKind()) {<br>
+ for (const auto &BI : *CurrBlock) {<br>
+ switch (BI.getKind()) {<br>
case CFGElement::Statement:<br>
- Visitor.Visit(BI->castAs<CFGStmt>().getStmt());<br>
+ Visitor.Visit(BI.castAs<CFGStmt>().getStmt());<br>
break;<br>
<br>
case CFGElement::TemporaryDtor: {<br>
- const CFGTemporaryDtor DTor = BI->castAs<CFGTemporaryDtor>();<br>
+ const CFGTemporaryDtor &DTor = BI.castAs<CFGTemporaryDtor>();<br>
const CXXBindTemporaryExpr *BTE = DTor.getBindTemporaryExpr();<br>
<br>
Visitor.checkCallability(PropagationInfo(BTE),<br>
@@ -1440,7 +1421,7 @@ void ConsumedAnalyzer::run(AnalysisDeclC<br>
}<br>
<br>
case CFGElement::AutomaticObjectDtor: {<br>
- const CFGAutomaticObjDtor DTor = BI->castAs<CFGAutomaticObjDtor>();<br>
+ const CFGAutomaticObjDtor &DTor = BI.castAs<CFGAutomaticObjDtor>();<br>
SourceLocation Loc = DTor.getTriggerStmt()->getLocEnd();<br>
const VarDecl *Var = DTor.getVarDecl();<br>
<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div>