summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2011-02-13 04:07:26 +0000
committerJohn McCall <rjmccall@apple.com>2011-02-13 04:07:26 +0000
commit7502c1d3ce8bb97bcc4f7bebef507040bd93b26f (patch)
treea8483d8d96d4c459027291b90fad493b985313cb
parent0d70d71ccbc4f7f59cadb759f61b7172a149676c (diff)
downloadclang-7502c1d3ce8bb97bcc4f7bebef507040bd93b26f.tar.gz
clang-7502c1d3ce8bb97bcc4f7bebef507040bd93b26f.tar.bz2
clang-7502c1d3ce8bb97bcc4f7bebef507040bd93b26f.tar.xz
Give some convenient idiomatic accessors to Stmt::child_range and
Stmt::const_child_range, then make a bunch of places use them instead of the individual iterator accessors. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125450 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/EvaluatedExprVisitor.h3
-rw-r--r--include/clang/AST/RecursiveASTVisitor.h29
-rw-r--r--include/clang/AST/StmtIterator.h83
-rw-r--r--include/clang/Analysis/Visitors/CFGStmtVisitor.h2
-rw-r--r--include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h3
-rw-r--r--lib/AST/Expr.cpp6
-rw-r--r--lib/AST/ParentMap.cpp2
-rw-r--r--lib/AST/StmtDumper.cpp6
-rw-r--r--lib/AST/StmtProfile.cpp3
-rw-r--r--lib/Analysis/AnalysisContext.cpp2
-rw-r--r--lib/Analysis/CFG.cpp10
-rw-r--r--lib/Analysis/PseudoConstantAnalysis.cpp3
-rw-r--r--lib/Analysis/UninitializedValues.cpp2
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp3
-rw-r--r--lib/Frontend/StmtXML.cpp3
-rw-r--r--lib/Index/ASTVisitor.h3
-rw-r--r--lib/Index/CallGraph.cpp2
-rw-r--r--lib/Rewrite/RewriteObjC.cpp27
-rw-r--r--lib/Sema/JumpDiagnostics.cpp3
-rw-r--r--lib/Sema/SemaChecking.cpp3
-rw-r--r--lib/Sema/SemaDeclCXX.cpp9
-rw-r--r--tools/libclang/CIndex.cpp3
22 files changed, 126 insertions, 84 deletions
diff --git a/include/clang/AST/EvaluatedExprVisitor.h b/include/clang/AST/EvaluatedExprVisitor.h
index be606e0fda..5616d8822e 100644
--- a/include/clang/AST/EvaluatedExprVisitor.h
+++ b/include/clang/AST/EvaluatedExprVisitor.h
@@ -71,8 +71,7 @@ public:
/// \brief The basis case walks all of the children of the statement or
/// expression, assuming they are all potentially evaluated.
void VisitStmt(Stmt *S) {
- for(Stmt::child_iterator C = S->child_begin(), CEnd = S->child_end();
- C != CEnd; ++C)
+ for (Stmt::child_range C = S->children(); C; ++C)
this->Visit(*C);
}
};
diff --git a/include/clang/AST/RecursiveASTVisitor.h b/include/clang/AST/RecursiveASTVisitor.h
index 700dd8eb6b..8ddd5875ce 100644
--- a/include/clang/AST/RecursiveASTVisitor.h
+++ b/include/clang/AST/RecursiveASTVisitor.h
@@ -1561,12 +1561,11 @@ DEF_TRAVERSE_DECL(ParmVarDecl, {
// ----------------- Stmt traversal -----------------
//
// For stmts, we automate (in the DEF_TRAVERSE_STMT macro) iterating
-// over the children defined in child_begin/child_end (every stmt
-// defines these, though sometimes the range is empty). Each
-// individual Traverse* method only needs to worry about children
-// other than those. To see what child_begin()/end() does for a given
-// class, see, e.g.,
-// http://clang.llvm.org/doxygen/Stmt_8cpp_source.html
+// over the children defined in children() (every stmt defines these,
+// though sometimes the range is empty). Each individual Traverse*
+// method only needs to worry about children other than those. To see
+// what children() does for a given class, see, e.g.,
+// http://clang.llvm.org/doxygen/Stmt_8cpp_source.html
// This macro makes available a variable S, the passed-in stmt.
#define DEF_TRAVERSE_STMT(STMT, CODE) \
@@ -1574,9 +1573,8 @@ template<typename Derived> \
bool RecursiveASTVisitor<Derived>::Traverse##STMT (STMT *S) { \
TRY_TO(WalkUpFrom##STMT(S)); \
{ CODE; } \
- for (Stmt::child_iterator C = S->child_begin(), CEnd = S->child_end(); \
- C != CEnd; ++C) { \
- TRY_TO(TraverseStmt(*C)); \
+ for (Stmt::child_range range = S->children(); range; ++range) { \
+ TRY_TO(TraverseStmt(*range)); \
} \
return true; \
}
@@ -1592,12 +1590,12 @@ DEF_TRAVERSE_STMT(AsmStmt, {
for (unsigned I = 0, E = S->getNumClobbers(); I < E; ++I) {
TRY_TO(TraverseStmt(S->getClobber(I)));
}
- // child_begin()/end() iterates over inputExpr and outputExpr.
+ // children() iterates over inputExpr and outputExpr.
})
DEF_TRAVERSE_STMT(CXXCatchStmt, {
TRY_TO(TraverseDecl(S->getExceptionDecl()));
- // child_begin()/end() iterates over the handler block.
+ // children() iterates over the handler block.
})
DEF_TRAVERSE_STMT(DeclStmt, {
@@ -1605,11 +1603,11 @@ DEF_TRAVERSE_STMT(DeclStmt, {
I != E; ++I) {
TRY_TO(TraverseDecl(*I));
}
- // Suppress the default iteration over child_begin/end by
+ // Suppress the default iteration over children() by
// returning. Here's why: A DeclStmt looks like 'type var [=
// initializer]'. The decls above already traverse over the
// initializers, so we don't have to do it again (which
- // child_begin/end would do).
+ // children() would do).
return true;
})
@@ -1712,9 +1710,8 @@ bool RecursiveASTVisitor<Derived>::TraverseInitListExpr(InitListExpr *S) {
S = Syn;
TRY_TO(WalkUpFromInitListExpr(S));
// All we need are the default actions. FIXME: use a helper function.
- for (Stmt::child_iterator C = S->child_begin(), CEnd = S->child_end();
- C != CEnd; ++C) {
- TRY_TO(TraverseStmt(*C));
+ for (Stmt::child_range range = S->children(); range; ++range) {
+ TRY_TO(TraverseStmt(*range));
}
return true;
}
diff --git a/include/clang/AST/StmtIterator.h b/include/clang/AST/StmtIterator.h
index 0d4657bdcc..851c001adc 100644
--- a/include/clang/AST/StmtIterator.h
+++ b/include/clang/AST/StmtIterator.h
@@ -146,14 +146,85 @@ struct ConstStmtIterator : public StmtIteratorImpl<ConstStmtIterator,
StmtIteratorImpl<ConstStmtIterator,const Stmt*>(RHS) {}
};
-typedef std::pair<StmtIterator,StmtIterator> StmtRange;
-typedef std::pair<ConstStmtIterator,ConstStmtIterator> ConstStmtRange;
+/// A range of statement iterators.
+///
+/// This class provides some extra functionality beyond std::pair
+/// in order to allow the following idiom:
+/// for (StmtRange range = stmt->children(); range; ++range)
+struct StmtRange : std::pair<StmtIterator,StmtIterator> {
+ StmtRange() {}
+ StmtRange(const StmtIterator &begin, const StmtIterator &end)
+ : std::pair<StmtIterator,StmtIterator>(begin, end) {}
+
+ bool empty() const { return first == second; }
+ operator bool() const { return !empty(); }
+
+ Stmt *operator->() const { return first.operator->(); }
+ Stmt *&operator*() const { return first.operator*(); }
+
+ StmtRange &operator++() {
+ assert(!empty() && "incrementing on empty range");
+ ++first;
+ return *this;
+ }
-inline StmtIterator begin(StmtRange range) { return range.first; }
-inline StmtIterator end(StmtRange range) { return range.second; }
+ StmtRange operator++(int) {
+ assert(!empty() && "incrementing on empty range");
+ StmtRange copy = *this;
+ ++first;
+ return copy;
+ }
-inline ConstStmtIterator begin(ConstStmtRange range) { return range.first; }
-inline ConstStmtIterator end(ConstStmtRange range) { return range.second; }
+ friend const StmtIterator &begin(const StmtRange &range) {
+ return range.first;
+ }
+ friend const StmtIterator &end(const StmtRange &range) {
+ return range.second;
+ }
+};
+
+/// A range of const statement iterators.
+///
+/// This class provides some extra functionality beyond std::pair
+/// in order to allow the following idiom:
+/// for (ConstStmtRange range = stmt->children(); range; ++range)
+struct ConstStmtRange : std::pair<ConstStmtIterator,ConstStmtIterator> {
+ ConstStmtRange() {}
+ ConstStmtRange(const ConstStmtIterator &begin,
+ const ConstStmtIterator &end)
+ : std::pair<ConstStmtIterator,ConstStmtIterator>(begin, end) {}
+ ConstStmtRange(const StmtRange &range)
+ : std::pair<ConstStmtIterator,ConstStmtIterator>(range.first, range.second)
+ {}
+ ConstStmtRange(const StmtIterator &begin, const StmtIterator &end)
+ : std::pair<ConstStmtIterator,ConstStmtIterator>(begin, end) {}
+
+ bool empty() const { return first == second; }
+ operator bool() const { return !empty(); }
+
+ const Stmt *operator->() const { return first.operator->(); }
+ const Stmt *operator*() const { return first.operator*(); }
+
+ ConstStmtRange &operator++() {
+ assert(!empty() && "incrementing on empty range");
+ ++first;
+ return *this;
+ }
+
+ ConstStmtRange operator++(int) {
+ assert(!empty() && "incrementing on empty range");
+ ConstStmtRange copy = *this;
+ ++first;
+ return copy;
+ }
+
+ friend const ConstStmtIterator &begin(const ConstStmtRange &range) {
+ return range.first;
+ }
+ friend const ConstStmtIterator &end(const ConstStmtRange &range) {
+ return range.second;
+ }
+};
} // end namespace clang
diff --git a/include/clang/Analysis/Visitors/CFGStmtVisitor.h b/include/clang/Analysis/Visitors/CFGStmtVisitor.h
index 6421f185ff..2d59119f25 100644
--- a/include/clang/Analysis/Visitors/CFGStmtVisitor.h
+++ b/include/clang/Analysis/Visitors/CFGStmtVisitor.h
@@ -155,7 +155,7 @@ public:
}
}
- for (Stmt::child_iterator I=S->child_begin(), E=S->child_end(); I != E;++I)
+ for (Stmt::child_range I = S->children(); I; ++I)
if (*I) static_cast<ImplClass*>(this)->Visit(*I);
}
};
diff --git a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
index 005e0e5863..12547e0969 100644
--- a/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
+++ b/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
@@ -28,8 +28,7 @@ template <class T> bool containsStmt(const Stmt *S) {
if (isa<T>(S))
return true;
- for (Stmt::const_child_iterator I = S->child_begin(); I != S->child_end();
- ++I)
+ for (Stmt::const_child_range I = S->children(); I; ++I)
if (const Stmt *child = *I)
if (containsStmt<T>(child))
return true;
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp
index 6280d633aa..884a184b52 100644
--- a/lib/AST/Expr.cpp
+++ b/lib/AST/Expr.cpp
@@ -1594,9 +1594,7 @@ static Expr::CanThrowResult MergeCanThrow(Expr::CanThrowResult CT1,
static Expr::CanThrowResult CanSubExprsThrow(ASTContext &C, const Expr *CE) {
Expr *E = const_cast<Expr*>(CE);
Expr::CanThrowResult R = Expr::CT_Cannot;
- Expr::child_iterator I, IE;
- for (llvm::tie(I, IE) = E->children();
- I != IE && R != Expr::CT_Can; ++I) {
+ for (Expr::child_range I = E->children(); I && R != Expr::CT_Can; ++I) {
R = MergeCanThrow(R, cast<Expr>(*I)->CanThrow(C));
}
return R;
@@ -2593,7 +2591,7 @@ DesignatedInitExpr::DesignatedInitExpr(ASTContext &C, QualType Ty,
this->Designators = new (C) Designator[NumDesignators];
// Record the initializer itself.
- child_iterator Child = child_begin();
+ child_range Child = children();
*Child++ = Init;
// Copy the designators and their subexpressions, computing
diff --git a/lib/AST/ParentMap.cpp b/lib/AST/ParentMap.cpp
index 87f8f36e6e..eca351aec8 100644
--- a/lib/AST/ParentMap.cpp
+++ b/lib/AST/ParentMap.cpp
@@ -21,7 +21,7 @@ using namespace clang;
typedef llvm::DenseMap<Stmt*, Stmt*> MapTy;
static void BuildParentMap(MapTy& M, Stmt* S) {
- for (Stmt::child_iterator I=S->child_begin(), E=S->child_end(); I!=E; ++I)
+ for (Stmt::child_range I = S->children(); I; ++I)
if (*I) {
M[*I] = S;
BuildParentMap(M, *I);
diff --git a/lib/AST/StmtDumper.cpp b/lib/AST/StmtDumper.cpp
index 5def7d9a0b..e5e759d9ef 100644
--- a/lib/AST/StmtDumper.cpp
+++ b/lib/AST/StmtDumper.cpp
@@ -59,9 +59,9 @@ namespace {
Visit(S);
// Print out children.
- Stmt::child_iterator CI = S->child_begin(), CE = S->child_end();
- if (CI != CE) {
- while (CI != CE) {
+ Stmt::child_range CI = S->children();
+ if (CI) {
+ while (CI) {
OS << '\n';
DumpSubTree(*CI++);
}
diff --git a/lib/AST/StmtProfile.cpp b/lib/AST/StmtProfile.cpp
index 707cac4edf..b96ffe8a48 100644
--- a/lib/AST/StmtProfile.cpp
+++ b/lib/AST/StmtProfile.cpp
@@ -68,8 +68,7 @@ namespace {
void StmtProfiler::VisitStmt(Stmt *S) {
ID.AddInteger(S->getStmtClass());
- for (Stmt::child_iterator C = S->child_begin(), CEnd = S->child_end();
- C != CEnd; ++C)
+ for (Stmt::child_range C = S->children(); C; ++C)
Visit(*C);
}
diff --git a/lib/Analysis/AnalysisContext.cpp b/lib/Analysis/AnalysisContext.cpp
index d9ac1de3d1..5233d3b8f9 100644
--- a/lib/Analysis/AnalysisContext.cpp
+++ b/lib/Analysis/AnalysisContext.cpp
@@ -273,7 +273,7 @@ public:
}
void VisitStmt(Stmt *S) {
- for (Stmt::child_iterator I = S->child_begin(), E = S->child_end();I!=E;++I)
+ for (Stmt::child_range I = S->children(); I; ++I)
if (Stmt *child = *I)
Visit(child);
}
diff --git a/lib/Analysis/CFG.cpp b/lib/Analysis/CFG.cpp
index 2cf2751879..bc3699ba68 100644
--- a/lib/Analysis/CFG.cpp
+++ b/lib/Analysis/CFG.cpp
@@ -921,8 +921,7 @@ CFGBlock *CFGBuilder::VisitStmt(Stmt *S, AddStmtChoice asc) {
/// VisitChildren - Visit the children of a Stmt.
CFGBlock *CFGBuilder::VisitChildren(Stmt* Terminator) {
CFGBlock *B = Block;
- for (Stmt::child_iterator I = Terminator->child_begin(),
- E = Terminator->child_end(); I != E; ++I) {
+ for (Stmt::child_range I = Terminator->children(); I; ++I) {
if (*I) B = Visit(*I);
}
return B;
@@ -2503,8 +2502,7 @@ CFGBlock *CFGBuilder::VisitChildrenForTemporaryDtors(Stmt *E) {
// them in helper vector.
typedef llvm::SmallVector<Stmt *, 4> ChildrenVect;
ChildrenVect ChildrenRev;
- for (Stmt::child_iterator I = E->child_begin(), L = E->child_end();
- I != L; ++I) {
+ for (Stmt::child_range I = E->children(); I; ++I) {
if (*I) ChildrenRev.push_back(*I);
}
@@ -2697,7 +2695,7 @@ static void FindSubExprAssignments(Stmt *S,
if (!S)
return;
- for (Stmt::child_iterator I=S->child_begin(), E=S->child_end(); I!=E; ++I) {
+ for (Stmt::child_range I = S->children(); I; ++I) {
Stmt *child = *I;
if (!child)
continue;
@@ -3020,7 +3018,7 @@ static void print_elem(llvm::raw_ostream &OS, StmtPrinterHelper* Helper,
if (StmtExpr* SE = dyn_cast<StmtExpr>(S)) {
CompoundStmt* Sub = SE->getSubStmt();
- if (Sub->child_begin() != Sub->child_end()) {
+ if (Sub->children()) {
OS << "({ ... ; ";
Helper->handledStmt(*SE->getSubStmt()->body_rbegin(),OS);
OS << " })\n";
diff --git a/lib/Analysis/PseudoConstantAnalysis.cpp b/lib/Analysis/PseudoConstantAnalysis.cpp
index 25b04fc2e8..ff96eb4a0a 100644
--- a/lib/Analysis/PseudoConstantAnalysis.cpp
+++ b/lib/Analysis/PseudoConstantAnalysis.cpp
@@ -233,8 +233,7 @@ void PseudoConstantAnalysis::RunAnalysis() {
} // switch (head->getStmtClass())
// Add all substatements to the worklist
- for (Stmt::const_child_iterator I = Head->child_begin(),
- E = Head->child_end(); I != E; ++I)
+ for (Stmt::const_child_range I = Head->children(); I; ++I)
if (*I)
WorkList.push_back(*I);
} // while (!WorkList.empty())
diff --git a/lib/Analysis/UninitializedValues.cpp b/lib/Analysis/UninitializedValues.cpp
index 73bce8b3b7..570743268e 100644
--- a/lib/Analysis/UninitializedValues.cpp
+++ b/lib/Analysis/UninitializedValues.cpp
@@ -230,7 +230,7 @@ bool TransferFuncs::VisitStmt(Stmt* S) {
// We don't stop at the first subexpression that is Uninitialized because
// evaluating some subexpressions may result in propogating "Uninitialized"
// or "Initialized" to variables referenced in the other subexpressions.
- for (Stmt::child_iterator I=S->child_begin(), E=S->child_end(); I!=E; ++I)
+ for (Stmt::child_range I = S->children(); I; ++I)
if (*I && Visit(*I) == Uninitialized) x = Uninitialized;
return x;
diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp
index 5a4f2b70e3..38ca0214da 100644
--- a/lib/CodeGen/CodeGenFunction.cpp
+++ b/lib/CodeGen/CodeGenFunction.cpp
@@ -396,8 +396,7 @@ bool CodeGenFunction::ContainsLabel(const Stmt *S, bool IgnoreCaseStmts) {
IgnoreCaseStmts = true;
// Scan subexpressions for verboten labels.
- for (Stmt::const_child_iterator I = S->child_begin(), E = S->child_end();
- I != E; ++I)
+ for (Stmt::const_child_range I = S->children(); I; ++I)
if (ContainsLabel(*I, IgnoreCaseStmts))
return true;
diff --git a/lib/Frontend/StmtXML.cpp b/lib/Frontend/StmtXML.cpp
index c2ffe4f2a7..c113cc18dc 100644
--- a/lib/Frontend/StmtXML.cpp
+++ b/lib/Frontend/StmtXML.cpp
@@ -61,8 +61,7 @@ namespace {
Doc.PrintDecl(*DI);
}
} else {
- for (Stmt::child_iterator i = S->child_begin(), e = S->child_end();
- i != e; ++i)
+ for (Stmt::child_range i = S->children(); i; ++i)
DumpSubTree(*i);
}
Doc.toParent();
diff --git a/lib/Index/ASTVisitor.h b/lib/Index/ASTVisitor.h
index 943c720253..0b8425b2f3 100644
--- a/lib/Index/ASTVisitor.h
+++ b/lib/Index/ASTVisitor.h
@@ -108,8 +108,7 @@ public:
}
void VisitStmt(Stmt *Node) {
- for (Stmt::child_iterator
- I = Node->child_begin(), E = Node->child_end(); I != E; ++I)
+ for (Stmt::child_range I = Node->children(); I; ++I)
if (*I)
Visit(*I);
}
diff --git a/lib/Index/CallGraph.cpp b/lib/Index/CallGraph.cpp
index dedcc0e808..bf3f5a8a8d 100644
--- a/lib/Index/CallGraph.cpp
+++ b/lib/Index/CallGraph.cpp
@@ -40,7 +40,7 @@ public:
void VisitCallExpr(CallExpr *CE);
void VisitChildren(Stmt *S) {
- for (Stmt::child_iterator I=S->child_begin(), E=S->child_end(); I != E;++I)
+ for (Stmt::child_range I = S->children(); I; ++I)
if (*I)
static_cast<CGBuilder*>(this)->Visit(*I);
}
diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp
index cf11dc64c6..543439aac1 100644
--- a/lib/Rewrite/RewriteObjC.cpp
+++ b/lib/Rewrite/RewriteObjC.cpp
@@ -1491,8 +1491,7 @@ Stmt *RewriteObjC::RewriteObjCIvarRefExpr(ObjCIvarRefExpr *IV,
}
Stmt *RewriteObjC::RewriteObjCNestedIvarRefExpr(Stmt *S, bool &replaced) {
- for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
- CI != E; ++CI) {
+ for (Stmt::child_range CI = S->children(); CI; ++CI) {
if (*CI) {
Stmt *newStmt = RewriteObjCNestedIvarRefExpr(*CI, replaced);
if (newStmt)
@@ -1837,8 +1836,7 @@ Stmt *RewriteObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
void RewriteObjC::WarnAboutReturnGotoStmts(Stmt *S)
{
// Perform a bottom up traversal of all children.
- for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
- CI != E; ++CI)
+ for (Stmt::child_range CI = S->children(); CI; ++CI)
if (*CI)
WarnAboutReturnGotoStmts(*CI);
@@ -1852,8 +1850,7 @@ void RewriteObjC::WarnAboutReturnGotoStmts(Stmt *S)
void RewriteObjC::HasReturnStmts(Stmt *S, bool &hasReturns)
{
// Perform a bottom up traversal of all children.
- for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
- CI != E; ++CI)
+ for (Stmt::child_range CI = S->children(); CI; ++CI)
if (*CI)
HasReturnStmts(*CI, hasReturns);
@@ -1864,8 +1861,7 @@ void RewriteObjC::HasReturnStmts(Stmt *S, bool &hasReturns)
void RewriteObjC::RewriteTryReturnStmts(Stmt *S) {
// Perform a bottom up traversal of all children.
- for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
- CI != E; ++CI)
+ for (Stmt::child_range CI = S->children(); CI; ++CI)
if (*CI) {
RewriteTryReturnStmts(*CI);
}
@@ -1888,8 +1884,7 @@ void RewriteObjC::RewriteTryReturnStmts(Stmt *S) {
void RewriteObjC::RewriteSyncReturnStmts(Stmt *S, std::string syncExitBuf) {
// Perform a bottom up traversal of all children.
- for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
- CI != E; ++CI)
+ for (Stmt::child_range CI = S->children(); CI; ++CI)
if (*CI) {
RewriteSyncReturnStmts(*CI, syncExitBuf);
}
@@ -4545,8 +4540,7 @@ void RewriteObjC::InsertBlockLiteralsWithinMethod(ObjCMethodDecl *MD) {
}
void RewriteObjC::GetBlockDeclRefExprs(Stmt *S) {
- for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
- CI != E; ++CI)
+ for (Stmt::child_range CI = S->children(); CI; ++CI)
if (*CI) {
if (BlockExpr *CBE = dyn_cast<BlockExpr>(*CI))
GetBlockDeclRefExprs(CBE->getBody());
@@ -4574,8 +4568,7 @@ void RewriteObjC::GetBlockDeclRefExprs(Stmt *S) {
void RewriteObjC::GetInnerBlockDeclRefExprs(Stmt *S,
llvm::SmallVector<BlockDeclRefExpr *, 8> &InnerBlockDeclRefs,
llvm::SmallPtrSet<const DeclContext *, 8> &InnerContexts) {
- for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
- CI != E; ++CI)
+ for (Stmt::child_range CI = S->children(); CI; ++CI)
if (*CI) {
if (BlockExpr *CBE = dyn_cast<BlockExpr>(*CI)) {
InnerContexts.insert(cast<DeclContext>(CBE->getBlockDecl()));
@@ -5463,8 +5456,7 @@ Stmt *RewriteObjC::SynthBlockInitExpr(BlockExpr *Exp,
// we get this right.
void RewriteObjC::CollectPropertySetters(Stmt *S) {
// Perform a bottom up traversal of all children.
- for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
- CI != E; ++CI)
+ for (Stmt::child_range CI = S->children(); CI; ++CI)
if (*CI)
CollectPropertySetters(*CI);
@@ -5488,8 +5480,7 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
SourceRange OrigStmtRange = S->getSourceRange();
// Perform a bottom up rewrite of all children.
- for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end();
- CI != E; ++CI)
+ for (Stmt::child_range CI = S->children(); CI; ++CI)
if (*CI) {
Stmt *newStmt;
Stmt *S = (*CI);
diff --git a/lib/Sema/JumpDiagnostics.cpp b/lib/Sema/JumpDiagnostics.cpp
index bbe7bd5b28..bd6b48a30f 100644
--- a/lib/Sema/JumpDiagnostics.cpp
+++ b/lib/Sema/JumpDiagnostics.cpp
@@ -221,8 +221,7 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, unsigned ParentScope) {
break;
}
- for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end(); CI != E;
- ++CI) {
+ for (Stmt::child_range CI = S->children(); CI; ++CI) {
if (SkipFirstSubStmt) {
SkipFirstSubStmt = false;
continue;
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp
index 24dcfb62a1..03ce7f3708 100644
--- a/lib/Sema/SemaChecking.cpp
+++ b/lib/Sema/SemaChecking.cpp
@@ -2954,8 +2954,7 @@ void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC) {
// Now just recurse over the expression's children.
CC = E->getExprLoc();
- for (Stmt::child_iterator I = E->child_begin(), IE = E->child_end();
- I != IE; ++I)
+ for (Stmt::child_range I = E->children(); I; ++I)
AnalyzeImplicitConversions(S, cast<Expr>(*I), CC);
}
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index 90ec795005..cc3a02fb2a 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -63,8 +63,7 @@ namespace {
/// VisitExpr - Visit all of the children of this expression.
bool CheckDefaultArgumentVisitor::VisitExpr(Expr *Node) {
bool IsInvalid = false;
- for (Stmt::child_iterator I = Node->child_begin(),
- E = Node->child_end(); I != E; ++I)
+ for (Stmt::child_range I = Node->children(); I; ++I)
IsInvalid |= Visit(*I);
return IsInvalid;
}
@@ -1365,8 +1364,7 @@ static bool InitExprContainsUninitializedFields(const Stmt *S,
if (UOE->getOpcode() == UO_AddrOf)
return false;
}
- for (Stmt::const_child_iterator it = S->child_begin(), e = S->child_end();
- it != e; ++it) {
+ for (Stmt::const_child_range it = S->children(); it; ++it) {
if (!*it) {
// An expression such as 'member(arg ?: "")' may trigger this.
continue;
@@ -7199,8 +7197,7 @@ void Sema::SetDeclDeleted(Decl *Dcl, SourceLocation DelLoc) {
}
static void SearchForReturnInStmt(Sema &Self, Stmt *S) {
- for (Stmt::child_iterator CI = S->child_begin(), E = S->child_end(); CI != E;
- ++CI) {
+ for (Stmt::child_range CI = S->children(); CI; ++CI) {
Stmt *SubStmt = *CI;
if (!SubStmt)
continue;
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 32e0039b0d..88091006a8 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -1686,8 +1686,7 @@ void EnqueueVisitor::AddTypeLoc(TypeSourceInfo *TI) {
}
void EnqueueVisitor::EnqueueChildren(Stmt *S) {
unsigned size = WL.size();
- for (Stmt::child_iterator Child = S->child_begin(), ChildEnd = S->child_end();
- Child != ChildEnd; ++Child) {
+ for (Stmt::child_range Child = S->children(); Child; ++Child) {
AddStmt(*Child);
}
if (size == WL.size())