forked from OSchip/llvm-project
[C++11] Converting to range-based for loops. No functional changes intended.
llvm-svn: 207416
This commit is contained in:
parent
4f9c31a2fa
commit
fe46e62e99
|
@ -57,11 +57,9 @@ ConsumedWarningsHandlerBase::~ConsumedWarningsHandlerBase() {}
|
||||||
static SourceLocation getFirstStmtLoc(const CFGBlock *Block) {
|
static SourceLocation getFirstStmtLoc(const CFGBlock *Block) {
|
||||||
// Find the source location of the first statement in the block, if the block
|
// Find the source location of the first statement in the block, if the block
|
||||||
// is not empty.
|
// is not empty.
|
||||||
for (CFGBlock::const_iterator BI = Block->begin(), BE = Block->end();
|
for (const auto &BI : *Block)
|
||||||
BI != BE; ++BI) {
|
if (Optional<CFGStmt> CS = BI.getAs<CFGStmt>())
|
||||||
if (Optional<CFGStmt> CS = BI->getAs<CFGStmt>())
|
|
||||||
return CS->getStmt()->getLocStart();
|
return CS->getStmt()->getLocStart();
|
||||||
}
|
|
||||||
|
|
||||||
// Block is empty.
|
// Block is empty.
|
||||||
// If we have one successor, return the first statement in that block
|
// If we have one successor, return the first statement in that block
|
||||||
|
@ -1144,21 +1142,19 @@ bool ConsumedBlockInfo::isBackEdgeTarget(const CFGBlock *Block) {
|
||||||
void ConsumedStateMap::checkParamsForReturnTypestate(SourceLocation BlameLoc,
|
void ConsumedStateMap::checkParamsForReturnTypestate(SourceLocation BlameLoc,
|
||||||
ConsumedWarningsHandlerBase &WarningsHandler) const {
|
ConsumedWarningsHandlerBase &WarningsHandler) const {
|
||||||
|
|
||||||
for (VarMapType::const_iterator DMI = VarMap.begin(), DME = VarMap.end();
|
for (const auto &DMI : VarMap) {
|
||||||
DMI != DME; ++DMI) {
|
if (isa<ParmVarDecl>(DMI.first)) {
|
||||||
|
const ParmVarDecl *Param = cast<ParmVarDecl>(DMI.first);
|
||||||
if (isa<ParmVarDecl>(DMI->first)) {
|
|
||||||
const ParmVarDecl *Param = cast<ParmVarDecl>(DMI->first);
|
|
||||||
const ReturnTypestateAttr *RTA = Param->getAttr<ReturnTypestateAttr>();
|
const ReturnTypestateAttr *RTA = Param->getAttr<ReturnTypestateAttr>();
|
||||||
|
|
||||||
if (!RTA)
|
if (!RTA)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
ConsumedState ExpectedState = mapReturnTypestateAttrState(RTA);
|
ConsumedState ExpectedState = mapReturnTypestateAttrState(RTA);
|
||||||
if (DMI->second != ExpectedState)
|
if (DMI.second != ExpectedState)
|
||||||
WarningsHandler.warnParamReturnTypestateMismatch(BlameLoc,
|
WarningsHandler.warnParamReturnTypestateMismatch(BlameLoc,
|
||||||
Param->getNameAsString(), stateToString(ExpectedState),
|
Param->getNameAsString(), stateToString(ExpectedState),
|
||||||
stateToString(DMI->second));
|
stateToString(DMI.second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1194,16 +1190,14 @@ void ConsumedStateMap::intersect(const ConsumedStateMap *Other) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (VarMapType::const_iterator DMI = Other->VarMap.begin(),
|
for (const auto &DMI : Other->VarMap) {
|
||||||
DME = Other->VarMap.end(); DMI != DME; ++DMI) {
|
LocalState = this->getState(DMI.first);
|
||||||
|
|
||||||
LocalState = this->getState(DMI->first);
|
|
||||||
|
|
||||||
if (LocalState == CS_None)
|
if (LocalState == CS_None)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (LocalState != DMI->second)
|
if (LocalState != DMI.second)
|
||||||
VarMap[DMI->first] = CS_Unknown;
|
VarMap[DMI.first] = CS_Unknown;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1214,18 +1208,16 @@ void ConsumedStateMap::intersectAtLoopHead(const CFGBlock *LoopHead,
|
||||||
ConsumedState LocalState;
|
ConsumedState LocalState;
|
||||||
SourceLocation BlameLoc = getLastStmtLoc(LoopBack);
|
SourceLocation BlameLoc = getLastStmtLoc(LoopBack);
|
||||||
|
|
||||||
for (VarMapType::const_iterator DMI = LoopBackStates->VarMap.begin(),
|
for (const auto &DMI : LoopBackStates->VarMap) {
|
||||||
DME = LoopBackStates->VarMap.end(); DMI != DME; ++DMI) {
|
LocalState = this->getState(DMI.first);
|
||||||
|
|
||||||
LocalState = this->getState(DMI->first);
|
|
||||||
|
|
||||||
if (LocalState == CS_None)
|
if (LocalState == CS_None)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (LocalState != DMI->second) {
|
if (LocalState != DMI.second) {
|
||||||
VarMap[DMI->first] = CS_Unknown;
|
VarMap[DMI.first] = CS_Unknown;
|
||||||
WarningsHandler.warnLoopStateMismatch(
|
WarningsHandler.warnLoopStateMismatch(BlameLoc,
|
||||||
BlameLoc, DMI->first->getNameAsString());
|
DMI.first->getNameAsString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1250,13 +1242,9 @@ void ConsumedStateMap::remove(const VarDecl *Var) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConsumedStateMap::operator!=(const ConsumedStateMap *Other) const {
|
bool ConsumedStateMap::operator!=(const ConsumedStateMap *Other) const {
|
||||||
for (VarMapType::const_iterator DMI = Other->VarMap.begin(),
|
for (const auto &DMI : Other->VarMap)
|
||||||
DME = Other->VarMap.end(); DMI != DME; ++DMI) {
|
if (this->getState(DMI.first) != DMI.second)
|
||||||
|
return true;
|
||||||
if (this->getState(DMI->first) != DMI->second)
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1396,16 +1384,11 @@ void ConsumedAnalyzer::run(AnalysisDeclContext &AC) {
|
||||||
ConsumedStmtVisitor Visitor(AC, *this, CurrStates);
|
ConsumedStmtVisitor Visitor(AC, *this, CurrStates);
|
||||||
|
|
||||||
// Add all trackable parameters to the state map.
|
// Add all trackable parameters to the state map.
|
||||||
for (auto PI : D->params()) {
|
for (const auto *PI : D->params())
|
||||||
Visitor.VisitParmVarDecl(PI);
|
Visitor.VisitParmVarDecl(PI);
|
||||||
}
|
|
||||||
|
|
||||||
// Visit all of the function's basic blocks.
|
// Visit all of the function's basic blocks.
|
||||||
for (PostOrderCFGView::iterator I = SortedGraph->begin(),
|
for (const auto *CurrBlock : *SortedGraph) {
|
||||||
E = SortedGraph->end(); I != E; ++I) {
|
|
||||||
|
|
||||||
const CFGBlock *CurrBlock = *I;
|
|
||||||
|
|
||||||
if (CurrStates == NULL)
|
if (CurrStates == NULL)
|
||||||
CurrStates = BlockInfo.getInfo(CurrBlock);
|
CurrStates = BlockInfo.getInfo(CurrBlock);
|
||||||
|
|
||||||
|
@ -1421,16 +1404,14 @@ void ConsumedAnalyzer::run(AnalysisDeclContext &AC) {
|
||||||
Visitor.reset(CurrStates);
|
Visitor.reset(CurrStates);
|
||||||
|
|
||||||
// Visit all of the basic block's statements.
|
// Visit all of the basic block's statements.
|
||||||
for (CFGBlock::const_iterator BI = CurrBlock->begin(),
|
for (const auto &BI : *CurrBlock) {
|
||||||
BE = CurrBlock->end(); BI != BE; ++BI) {
|
switch (BI.getKind()) {
|
||||||
|
|
||||||
switch (BI->getKind()) {
|
|
||||||
case CFGElement::Statement:
|
case CFGElement::Statement:
|
||||||
Visitor.Visit(BI->castAs<CFGStmt>().getStmt());
|
Visitor.Visit(BI.castAs<CFGStmt>().getStmt());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CFGElement::TemporaryDtor: {
|
case CFGElement::TemporaryDtor: {
|
||||||
const CFGTemporaryDtor DTor = BI->castAs<CFGTemporaryDtor>();
|
const CFGTemporaryDtor &DTor = BI.castAs<CFGTemporaryDtor>();
|
||||||
const CXXBindTemporaryExpr *BTE = DTor.getBindTemporaryExpr();
|
const CXXBindTemporaryExpr *BTE = DTor.getBindTemporaryExpr();
|
||||||
|
|
||||||
Visitor.checkCallability(PropagationInfo(BTE),
|
Visitor.checkCallability(PropagationInfo(BTE),
|
||||||
|
@ -1440,7 +1421,7 @@ void ConsumedAnalyzer::run(AnalysisDeclContext &AC) {
|
||||||
}
|
}
|
||||||
|
|
||||||
case CFGElement::AutomaticObjectDtor: {
|
case CFGElement::AutomaticObjectDtor: {
|
||||||
const CFGAutomaticObjDtor DTor = BI->castAs<CFGAutomaticObjDtor>();
|
const CFGAutomaticObjDtor &DTor = BI.castAs<CFGAutomaticObjDtor>();
|
||||||
SourceLocation Loc = DTor.getTriggerStmt()->getLocEnd();
|
SourceLocation Loc = DTor.getTriggerStmt()->getLocEnd();
|
||||||
const VarDecl *Var = DTor.getVarDecl();
|
const VarDecl *Var = DTor.getVarDecl();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue