forked from OSchip/llvm-project
[clang] Convert a few loops to for-each
This commit is contained in:
parent
144f851f6f
commit
00ca004dda
|
@ -2724,11 +2724,10 @@ CFGBlock *CFGBuilder::VisitCompoundStmt(CompoundStmt *C,
|
||||||
|
|
||||||
CFGBlock *LastBlock = Block;
|
CFGBlock *LastBlock = Block;
|
||||||
|
|
||||||
for (CompoundStmt::reverse_body_iterator I=C->body_rbegin(), E=C->body_rend();
|
for (Stmt *S : llvm::reverse(C->body())) {
|
||||||
I != E; ++I ) {
|
|
||||||
// If we hit a segment of code just containing ';' (NullStmts), we can
|
// If we hit a segment of code just containing ';' (NullStmts), we can
|
||||||
// get a null block back. In such cases, just use the LastBlock
|
// get a null block back. In such cases, just use the LastBlock
|
||||||
CFGBlock *newBlock = Visit(*I, AddStmtChoice::AlwaysAdd,
|
CFGBlock *newBlock = Visit(S, AddStmtChoice::AlwaysAdd,
|
||||||
ExternallyDestructed);
|
ExternallyDestructed);
|
||||||
|
|
||||||
if (newBlock)
|
if (newBlock)
|
||||||
|
|
|
@ -1079,11 +1079,9 @@ namespace {
|
||||||
while (!BlockQueue.empty()) {
|
while (!BlockQueue.empty()) {
|
||||||
const CFGBlock *P = BlockQueue.front();
|
const CFGBlock *P = BlockQueue.front();
|
||||||
BlockQueue.pop_front();
|
BlockQueue.pop_front();
|
||||||
for (CFGBlock::const_succ_iterator I = P->succ_begin(),
|
for (const CFGBlock *B : P->succs()) {
|
||||||
E = P->succ_end();
|
if (B && ReachableBlocks.insert(B).second)
|
||||||
I != E; ++I) {
|
BlockQueue.push_back(B);
|
||||||
if (*I && ReachableBlocks.insert(*I).second)
|
|
||||||
BlockQueue.push_back(*I);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -630,8 +630,7 @@ public:
|
||||||
const CompoundStmt *Scope) {
|
const CompoundStmt *Scope) {
|
||||||
LastDeclUSEFinder Visitor;
|
LastDeclUSEFinder Visitor;
|
||||||
Visitor.D = D;
|
Visitor.D = D;
|
||||||
for (auto I = Scope->body_rbegin(), E = Scope->body_rend(); I != E; ++I) {
|
for (const Stmt *S : llvm::reverse(Scope->body())) {
|
||||||
const Stmt *S = *I;
|
|
||||||
if (!Visitor.TraverseStmt(const_cast<Stmt *>(S)))
|
if (!Visitor.TraverseStmt(const_cast<Stmt *>(S)))
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue