[clang] 00ca004 - [clang] Convert a few loops to for-each
Nico Weber via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 11 11:25:22 PDT 2021
Author: Nico Weber
Date: 2021-10-11T14:24:32-04:00
New Revision: 00ca004dda3215dce98cf081cd6b1ee8b7a8b3d6
URL: https://github.com/llvm/llvm-project/commit/00ca004dda3215dce98cf081cd6b1ee8b7a8b3d6
DIFF: https://github.com/llvm/llvm-project/commit/00ca004dda3215dce98cf081cd6b1ee8b7a8b3d6.diff
LOG: [clang] Convert a few loops to for-each
Added:
Modified:
clang/lib/Analysis/CFG.cpp
clang/lib/Sema/AnalysisBasedWarnings.cpp
clang/lib/Sema/SemaAvailability.cpp
Removed:
################################################################################
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index b1afbbc7a14d..306da631d34a 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -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)
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index 30bceb085bb9..2b089ff084ca 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -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);
}
}
}
diff --git a/clang/lib/Sema/SemaAvailability.cpp b/clang/lib/Sema/SemaAvailability.cpp
index d1c3d25b089d..dc15c87cb717 100644
--- a/clang/lib/Sema/SemaAvailability.cpp
+++ b/clang/lib/Sema/SemaAvailability.cpp
@@ -630,8 +630,7 @@ class LastDeclUSEFinder : public RecursiveASTVisitor<LastDeclUSEFinder> {
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;
}
More information about the cfe-commits
mailing list