[clang] Convert a few loops to for-each

This commit is contained in:
Nico Weber 2021-10-11 14:24:32 -04:00
parent 144f851f6f
commit 00ca004dda
3 changed files with 6 additions and 10 deletions

View File

@ -2724,11 +2724,10 @@ CFGBlock *CFGBuilder::VisitCompoundStmt(CompoundStmt *C,
CFGBlock *LastBlock = Block;
for (CompoundStmt::reverse_body_iterator I=C->body_rbegin(), E=C->body_rend();
I != E; ++I ) {
for (Stmt *S : llvm::reverse(C->body())) {
// If we hit a segment of code just containing ';' (NullStmts), we can
// 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);
if (newBlock)

View File

@ -1079,11 +1079,9 @@ namespace {
while (!BlockQueue.empty()) {
const CFGBlock *P = BlockQueue.front();
BlockQueue.pop_front();
for (CFGBlock::const_succ_iterator I = P->succ_begin(),
E = P->succ_end();
I != E; ++I) {
if (*I && ReachableBlocks.insert(*I).second)
BlockQueue.push_back(*I);
for (const CFGBlock *B : P->succs()) {
if (B && ReachableBlocks.insert(B).second)
BlockQueue.push_back(B);
}
}
}

View File

@ -630,8 +630,7 @@ public:
const CompoundStmt *Scope) {
LastDeclUSEFinder Visitor;
Visitor.D = D;
for (auto I = Scope->body_rbegin(), E = Scope->body_rend(); I != E; ++I) {
const Stmt *S = *I;
for (const Stmt *S : llvm::reverse(Scope->body())) {
if (!Visitor.TraverseStmt(const_cast<Stmt *>(S)))
return S;
}