summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/ARCMigrate/ObjCMT.cpp4
-rw-r--r--clang/lib/AST/ASTDumper.cpp4
-rw-r--r--clang/lib/AST/Expr.cpp8
-rw-r--r--clang/lib/AST/ParentMap.cpp12
-rw-r--r--clang/lib/AST/StmtProfile.cpp6
-rw-r--r--clang/lib/Analysis/AnalysisDeclContext.cpp6
-rw-r--r--clang/lib/Analysis/CFG.cpp11
-rw-r--r--clang/lib/Analysis/CallGraph.cpp6
-rw-r--r--clang/lib/Analysis/PseudoConstantAnalysis.cpp6
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp10
-rw-r--r--clang/lib/CodeGen/CGStmtOpenMP.cpp5
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp8
-rw-r--r--clang/lib/CodeGen/CodeGenPGO.cpp7
-rw-r--r--clang/lib/CodeGen/CoverageMappingGen.cpp7
-rw-r--r--clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp32
-rw-r--r--clang/lib/Frontend/Rewrite/RewriteObjC.cpp50
-rw-r--r--clang/lib/Sema/AnalysisBasedWarnings.cpp9
-rw-r--r--clang/lib/Sema/JumpDiagnostics.cpp3
-rw-r--r--clang/lib/Sema/SemaChecking.cpp4
-rw-r--r--clang/lib/Sema/SemaDeclCXX.cpp19
-rw-r--r--clang/lib/Sema/SemaExceptionSpec.cpp10
-rw-r--r--clang/lib/Sema/SemaOpenMP.cpp6
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp6
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp6
24 files changed, 116 insertions, 129 deletions
diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp
index 8c2e0f4de80..b61a421ce41 100644
--- a/clang/lib/ARCMigrate/ObjCMT.cpp
+++ b/clang/lib/ARCMigrate/ObjCMT.cpp
@@ -355,8 +355,8 @@ public:
bool TraverseObjCMessageExpr(ObjCMessageExpr *E) {
// Do depth first; we want to rewrite the subexpressions first so that if
// we have to move expressions we will move them already rewritten.
- for (Stmt::child_range range = E->children(); range; ++range)
- if (!TraverseStmt(*range))
+ for (Stmt *SubStmt : E->children())
+ if (!TraverseStmt(SubStmt))
return false;
return WalkUpFromObjCMessageExpr(E);
diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp
index 61d52f1baf6..90da4167197 100644
--- a/clang/lib/AST/ASTDumper.cpp
+++ b/clang/lib/AST/ASTDumper.cpp
@@ -1599,8 +1599,8 @@ void ASTDumper::dumpStmt(const Stmt *S) {
ConstStmtVisitor<ASTDumper>::Visit(S);
- for (Stmt::const_child_range CI = S->children(); CI; ++CI)
- dumpStmt(*CI);
+ for (const Stmt *SubStmt : S->children())
+ dumpStmt(SubStmt);
});
}
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 36f4139f835..87f9ffba78e 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -3154,10 +3154,10 @@ bool Expr::HasSideEffects(const ASTContext &Ctx,
}
// Recurse to children.
- for (const_child_range SubStmts = children(); SubStmts; ++SubStmts)
- if (const Stmt *S = *SubStmts)
- if (cast<Expr>(S)->HasSideEffects(Ctx, IncludePossibleEffects))
- return true;
+ for (const Stmt *SubStmt : children())
+ if (SubStmt &&
+ cast<Expr>(SubStmt)->HasSideEffects(Ctx, IncludePossibleEffects))
+ return true;
return false;
}
diff --git a/clang/lib/AST/ParentMap.cpp b/clang/lib/AST/ParentMap.cpp
index a991302a254..d7d5f9c6920 100644
--- a/clang/lib/AST/ParentMap.cpp
+++ b/clang/lib/AST/ParentMap.cpp
@@ -36,8 +36,8 @@ static void BuildParentMap(MapTy& M, Stmt* S,
// If we are rebuilding the map, clear out any existing state.
if (M[POE->getSyntacticForm()])
- for (Stmt::child_range I = S->children(); I; ++I)
- M[*I] = nullptr;
+ for (Stmt *SubStmt : S->children())
+ M[SubStmt] = nullptr;
M[POE->getSyntacticForm()] = S;
BuildParentMap(M, POE->getSyntacticForm(), OV_Transparent);
@@ -82,10 +82,10 @@ static void BuildParentMap(MapTy& M, Stmt* S,
break;
}
default:
- for (Stmt::child_range I = S->children(); I; ++I) {
- if (*I) {
- M[*I] = S;
- BuildParentMap(M, *I, OVMode);
+ for (Stmt *SubStmt : S->children()) {
+ if (SubStmt) {
+ M[SubStmt] = S;
+ BuildParentMap(M, SubStmt, OVMode);
}
}
break;
diff --git a/clang/lib/AST/StmtProfile.cpp b/clang/lib/AST/StmtProfile.cpp
index 63f432ca4c3..da996920c42 100644
--- a/clang/lib/AST/StmtProfile.cpp
+++ b/clang/lib/AST/StmtProfile.cpp
@@ -69,9 +69,9 @@ namespace {
void StmtProfiler::VisitStmt(const Stmt *S) {
ID.AddInteger(S->getStmtClass());
- for (Stmt::const_child_range C = S->children(); C; ++C) {
- if (*C)
- Visit(*C);
+ for (const Stmt *SubStmt : S->children()) {
+ if (SubStmt)
+ Visit(SubStmt);
else
ID.AddInteger(0);
}
diff --git a/clang/lib/Analysis/AnalysisDeclContext.cpp b/clang/lib/Analysis/AnalysisDeclContext.cpp
index 4e623c8d6c3..d7fb7e95d75 100644
--- a/clang/lib/Analysis/AnalysisDeclContext.cpp
+++ b/clang/lib/Analysis/AnalysisDeclContext.cpp
@@ -472,9 +472,9 @@ public:
: BEVals(bevals), BC(bc) {}
void VisitStmt(Stmt *S) {
- for (Stmt::child_range I = S->children(); I; ++I)
- if (Stmt *child = *I)
- Visit(child);
+ for (Stmt *Child : S->children())
+ if (Child)
+ Visit(Child);
}
void VisitDeclRefExpr(DeclRefExpr *DR) {
diff --git a/clang/lib/Analysis/CFG.cpp b/clang/lib/Analysis/CFG.cpp
index 19b3f5a4765..54d15bd232a 100644
--- a/clang/lib/Analysis/CFG.cpp
+++ b/clang/lib/Analysis/CFG.cpp
@@ -270,9 +270,8 @@ reverse_children::reverse_children(Stmt *S) {
}
// Default case for all other statements.
- for (Stmt::child_range I = S->children(); I; ++I) {
- childrenBuf.push_back(*I);
- }
+ for (Stmt *SubStmt : S->children())
+ childrenBuf.push_back(SubStmt);
// This needs to be done *after* childrenBuf has been populated.
children = childrenBuf;
@@ -3641,11 +3640,11 @@ CFGBlock *CFGBuilder::VisitChildrenForTemporaryDtors(Stmt *E,
// bottom-up, this means we visit them in their natural order, which
// reverses them in the CFG.
CFGBlock *B = Block;
- for (Stmt::child_range I = E->children(); I; ++I) {
- if (Stmt *Child = *I)
+ for (Stmt *Child : E->children())
+ if (Child)
if (CFGBlock *R = VisitForTemporaryDtors(Child, false, Context))
B = R;
- }
+
return B;
}
diff --git a/clang/lib/Analysis/CallGraph.cpp b/clang/lib/Analysis/CallGraph.cpp
index 91a8492eaa5..d06603469dd 100644
--- a/clang/lib/Analysis/CallGraph.cpp
+++ b/clang/lib/Analysis/CallGraph.cpp
@@ -83,9 +83,9 @@ public:
}
void VisitChildren(Stmt *S) {
- for (Stmt::child_range I = S->children(); I; ++I)
- if (*I)
- static_cast<CGBuilder*>(this)->Visit(*I);
+ for (Stmt *SubStmt : S->children())
+ if (SubStmt)
+ this->Visit(SubStmt);
}
};
diff --git a/clang/lib/Analysis/PseudoConstantAnalysis.cpp b/clang/lib/Analysis/PseudoConstantAnalysis.cpp
index 3f96ca877f1..5b917a7a27f 100644
--- a/clang/lib/Analysis/PseudoConstantAnalysis.cpp
+++ b/clang/lib/Analysis/PseudoConstantAnalysis.cpp
@@ -220,8 +220,8 @@ void PseudoConstantAnalysis::RunAnalysis() {
} // switch (head->getStmtClass())
// Add all substatements to the worklist
- for (Stmt::const_child_range I = Head->children(); I; ++I)
- if (*I)
- WorkList.push_back(*I);
+ for (const Stmt *SubStmt : Head->children())
+ if (SubStmt)
+ WorkList.push_back(SubStmt);
} // while (!WorkList.empty())
}
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 07dbce4252f..839c2e474ca 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -579,9 +579,9 @@ static bool isAccessedBy(const VarDecl &var, const Stmt *s) {
}
}
- for (Stmt::const_child_range children = s->children(); children; ++children)
- // children might be null; as in missing decl or conditional of an if-stmt.
- if ((*children) && isAccessedBy(var, *children))
+ for (const Stmt *SubStmt : s->children())
+ // SubStmt might be null; as in missing decl or conditional of an if-stmt.
+ if (SubStmt && isAccessedBy(var, SubStmt))
return true;
return false;
@@ -1074,8 +1074,8 @@ static bool isCapturedBy(const VarDecl &var, const Expr *e) {
return false;
}
- for (Stmt::const_child_range children = e->children(); children; ++children)
- if (isCapturedBy(var, cast<Expr>(*children)))
+ for (const Stmt *SubStmt : e->children())
+ if (isCapturedBy(var, cast<Expr>(SubStmt)))
return true;
return false;
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index b297e2d10cb..de86d76ba26 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1266,12 +1266,13 @@ CodeGenFunction::EmitSections(const OMPExecutableDirective &S) {
CGF.EmitLoadOfLValue(IV, S.getLocStart()).getScalarVal(), ExitBB,
CS->size());
unsigned CaseNumber = 0;
- for (auto C = CS->children(); C; ++C, ++CaseNumber) {
+ for (auto *SubStmt : CS->children()) {
auto CaseBB = CGF.createBasicBlock(".omp.sections.case");
CGF.EmitBlock(CaseBB);
SwitchStmt->addCase(CGF.Builder.getInt32(CaseNumber), CaseBB);
- CGF.EmitStmt(*C);
+ CGF.EmitStmt(SubStmt);
CGF.EmitBranch(ExitBB);
+ ++CaseNumber;
}
CGF.EmitBlock(ExitBB, /*IsFinished=*/true);
};
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index bece41e9ecb..f1fc8c45f1e 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -970,8 +970,8 @@ bool CodeGenFunction::ContainsLabel(const Stmt *S, bool IgnoreCaseStmts) {
IgnoreCaseStmts = true;
// Scan subexpressions for verboten labels.
- for (Stmt::const_child_range I = S->children(); I; ++I)
- if (ContainsLabel(*I, IgnoreCaseStmts))
+ for (const Stmt *SubStmt : S->children())
+ if (ContainsLabel(SubStmt, IgnoreCaseStmts))
return true;
return false;
@@ -994,8 +994,8 @@ bool CodeGenFunction::containsBreak(const Stmt *S) {
return true;
// Scan subexpressions for verboten breaks.
- for (Stmt::const_child_range I = S->children(); I; ++I)
- if (containsBreak(*I))
+ for (const Stmt *SubStmt : S->children())
+ if (containsBreak(SubStmt))
return true;
return false;
diff --git a/clang/lib/CodeGen/CodeGenPGO.cpp b/clang/lib/CodeGen/CodeGenPGO.cpp
index f182a469b3a..8dffefc871f 100644
--- a/clang/lib/CodeGen/CodeGenPGO.cpp
+++ b/clang/lib/CodeGen/CodeGenPGO.cpp
@@ -275,10 +275,9 @@ struct ComputeRegionCounts : public ConstStmtVisitor<ComputeRegionCounts> {
void VisitStmt(const Stmt *S) {
RecordStmtCount(S);
- for (Stmt::const_child_range I = S->children(); I; ++I) {
- if (*I)
- this->Visit(*I);
- }
+ for (const Stmt *Child : S->children())
+ if (Child)
+ this->Visit(Child);
}
void VisitFunctionDecl(const FunctionDecl *D) {
diff --git a/clang/lib/CodeGen/CoverageMappingGen.cpp b/clang/lib/CodeGen/CoverageMappingGen.cpp
index 2467143faff..eca91590e60 100644
--- a/clang/lib/CodeGen/CoverageMappingGen.cpp
+++ b/clang/lib/CodeGen/CoverageMappingGen.cpp
@@ -582,10 +582,9 @@ struct CounterCoverageMappingBuilder
void VisitStmt(const Stmt *S) {
if (!S->getLocStart().isInvalid())
extendRegion(S);
- for (Stmt::const_child_range I = S->children(); I; ++I) {
- if (*I)
- this->Visit(*I);
- }
+ for (const Stmt *Child : S->children())
+ if (Child)
+ this->Visit(Child);
handleFileExit(getEnd(S));
}
diff --git a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
index e13cdb3a3e5..2902ba78c4e 100644
--- a/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
+++ b/clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
@@ -1932,9 +1932,9 @@ Stmt *RewriteModernObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S)
void RewriteModernObjC::WarnAboutReturnGotoStmts(Stmt *S)
{
// Perform a bottom up traversal of all children.
- for (Stmt::child_range CI = S->children(); CI; ++CI)
- if (*CI)
- WarnAboutReturnGotoStmts(*CI);
+ for (Stmt *SubStmt : S->children())
+ if (SubStmt)
+ WarnAboutReturnGotoStmts(SubStmt);
if (isa<ReturnStmt>(S) || isa<GotoStmt>(S)) {
Diags.Report(Context->getFullLoc(S->getLocStart()),
@@ -4549,12 +4549,12 @@ void RewriteModernObjC::InsertBlockLiteralsWithinMethod(ObjCMethodDecl *MD) {
}
void RewriteModernObjC::GetBlockDeclRefExprs(Stmt *S) {
- for (Stmt::child_range CI = S->children(); CI; ++CI)
- if (*CI) {
- if (BlockExpr *CBE = dyn_cast<BlockExpr>(*CI))
+ for (Stmt *SubStmt : S->children())
+ if (SubStmt) {
+ if (BlockExpr *CBE = dyn_cast<BlockExpr>(SubStmt))
GetBlockDeclRefExprs(CBE->getBody());
else
- GetBlockDeclRefExprs(*CI);
+ GetBlockDeclRefExprs(SubStmt);
}
// Handle specific things.
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S))
@@ -4569,19 +4569,16 @@ void RewriteModernObjC::GetBlockDeclRefExprs(Stmt *S) {
void RewriteModernObjC::GetInnerBlockDeclRefExprs(Stmt *S,
SmallVectorImpl<DeclRefExpr *> &InnerBlockDeclRefs,
llvm::SmallPtrSetImpl<const DeclContext *> &InnerContexts) {
- for (Stmt::child_range CI = S->children(); CI; ++CI)
- if (*CI) {
- if (BlockExpr *CBE = dyn_cast<BlockExpr>(*CI)) {
+ for (Stmt *SubStmt : S->children())
+ if (SubStmt) {
+ if (BlockExpr *CBE = dyn_cast<BlockExpr>(SubStmt)) {
InnerContexts.insert(cast<DeclContext>(CBE->getBlockDecl()));
GetInnerBlockDeclRefExprs(CBE->getBody(),
InnerBlockDeclRefs,
InnerContexts);
}
else
- GetInnerBlockDeclRefExprs(*CI,
- InnerBlockDeclRefs,
- InnerContexts);
-
+ GetInnerBlockDeclRefExprs(SubStmt, InnerBlockDeclRefs, InnerContexts);
}
// Handle specific things.
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) {
@@ -5564,12 +5561,11 @@ Stmt *RewriteModernObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
SourceRange OrigStmtRange = S->getSourceRange();
// Perform a bottom up rewrite of all children.
- for (Stmt::child_range CI = S->children(); CI; ++CI)
- if (*CI) {
- Stmt *childStmt = (*CI);
+ for (Stmt *&childStmt : S->children())
+ if (childStmt) {
Stmt *newStmt = RewriteFunctionBodyOrGlobalInitializer(childStmt);
if (newStmt) {
- *CI = newStmt;
+ childStmt = newStmt;
}
}
diff --git a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
index b2a45b407ba..204820b3041 100644
--- a/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
+++ b/clang/lib/Frontend/Rewrite/RewriteObjC.cpp
@@ -1712,9 +1712,9 @@ Stmt *RewriteObjC::RewriteObjCSynchronizedStmt(ObjCAtSynchronizedStmt *S) {
void RewriteObjC::WarnAboutReturnGotoStmts(Stmt *S)
{
// Perform a bottom up traversal of all children.
- for (Stmt::child_range CI = S->children(); CI; ++CI)
- if (*CI)
- WarnAboutReturnGotoStmts(*CI);
+ for (Stmt *SubStmt : S->children())
+ if (SubStmt)
+ WarnAboutReturnGotoStmts(SubStmt);
if (isa<ReturnStmt>(S) || isa<GotoStmt>(S)) {
Diags.Report(Context->getFullLoc(S->getLocStart()),
@@ -1726,9 +1726,9 @@ void RewriteObjC::WarnAboutReturnGotoStmts(Stmt *S)
void RewriteObjC::HasReturnStmts(Stmt *S, bool &hasReturns)
{
// Perform a bottom up traversal of all children.
- for (Stmt::child_range CI = S->children(); CI; ++CI)
- if (*CI)
- HasReturnStmts(*CI, hasReturns);
+ for (Stmt *SubStmt : S->children())
+ if (SubStmt)
+ HasReturnStmts(SubStmt, hasReturns);
if (isa<ReturnStmt>(S))
hasReturns = true;
@@ -1737,9 +1737,9 @@ void RewriteObjC::HasReturnStmts(Stmt *S, bool &hasReturns)
void RewriteObjC::RewriteTryReturnStmts(Stmt *S) {
// Perform a bottom up traversal of all children.
- for (Stmt::child_range CI = S->children(); CI; ++CI)
- if (*CI) {
- RewriteTryReturnStmts(*CI);
+ for (Stmt *SubStmt : S->children())
+ if (SubStmt) {
+ RewriteTryReturnStmts(SubStmt);
}
if (isa<ReturnStmt>(S)) {
SourceLocation startLoc = S->getLocStart();
@@ -1760,9 +1760,9 @@ void RewriteObjC::RewriteTryReturnStmts(Stmt *S) {
void RewriteObjC::RewriteSyncReturnStmts(Stmt *S, std::string syncExitBuf) {
// Perform a bottom up traversal of all children.
- for (Stmt::child_range CI = S->children(); CI; ++CI)
- if (*CI) {
- RewriteSyncReturnStmts(*CI, syncExitBuf);
+ for (Stmt *SubStmt : S->children())
+ if (SubStmt) {
+ RewriteSyncReturnStmts(SubStmt, syncExitBuf);
}
if (isa<ReturnStmt>(S)) {
SourceLocation startLoc = S->getLocStart();
@@ -3663,12 +3663,12 @@ void RewriteObjC::InsertBlockLiteralsWithinMethod(ObjCMethodDecl *MD) {
}
void RewriteObjC::GetBlockDeclRefExprs(Stmt *S) {
- for (Stmt::child_range CI = S->children(); CI; ++CI)
- if (*CI) {
- if (BlockExpr *CBE = dyn_cast<BlockExpr>(*CI))
+ for (Stmt *SubStmt : S->children())
+ if (SubStmt) {
+ if (BlockExpr *CBE = dyn_cast<BlockExpr>(SubStmt))
GetBlockDeclRefExprs(CBE->getBody());
else
- GetBlockDeclRefExprs(*CI);
+ GetBlockDeclRefExprs(SubStmt);
}
// Handle specific things.
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S))
@@ -3683,19 +3683,16 @@ void RewriteObjC::GetBlockDeclRefExprs(Stmt *S) {
void RewriteObjC::GetInnerBlockDeclRefExprs(Stmt *S,
SmallVectorImpl<DeclRefExpr *> &InnerBlockDeclRefs,
llvm::SmallPtrSetImpl<const DeclContext *> &InnerContexts) {
- for (Stmt::child_range CI = S->children(); CI; ++CI)
- if (*CI) {
- if (BlockExpr *CBE = dyn_cast<BlockExpr>(*CI)) {
+ for (Stmt *SubStmt : S->children())
+ if (SubStmt) {
+ if (BlockExpr *CBE = dyn_cast<BlockExpr>(SubStmt)) {
InnerContexts.insert(cast<DeclContext>(CBE->getBlockDecl()));
GetInnerBlockDeclRefExprs(CBE->getBody(),
InnerBlockDeclRefs,
InnerContexts);
}
else
- GetInnerBlockDeclRefExprs(*CI,
- InnerBlockDeclRefs,
- InnerContexts);
-
+ GetInnerBlockDeclRefExprs(SubStmt, InnerBlockDeclRefs, InnerContexts);
}
// Handle specific things.
if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(S)) {
@@ -4611,12 +4608,11 @@ Stmt *RewriteObjC::RewriteFunctionBodyOrGlobalInitializer(Stmt *S) {
SourceRange OrigStmtRange = S->getSourceRange();
// Perform a bottom up rewrite of all children.
- for (Stmt::child_range CI = S->children(); CI; ++CI)
- if (*CI) {
- Stmt *childStmt = (*CI);
+ for (Stmt *&childStmt : S->children())
+ if (childStmt) {
Stmt *newStmt = RewriteFunctionBodyOrGlobalInitializer(childStmt);
if (newStmt) {
- *CI = newStmt;
+ childStmt = newStmt;
}
}
diff --git a/clang/lib/Sema/AnalysisBasedWarnings.cpp b/clang/lib/Sema/AnalysisBasedWarnings.cpp
index 36030b99a30..f2ff48ad69f 100644
--- a/clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ b/clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -130,11 +130,10 @@ public:
return true;
// Recurse to children.
- for (ConstStmtRange SubStmts = E->children(); SubStmts; ++SubStmts)
- if (*SubStmts)
- if (const Expr *SubExpr = dyn_cast<Expr>(*SubStmts))
- if (HasMacroID(SubExpr))
- return true;
+ for (const Stmt *SubStmt : E->children())
+ if (const Expr *SubExpr = dyn_cast_or_null<Expr>(SubStmt))
+ if (HasMacroID(SubExpr))
+ return true;
return false;
}
diff --git a/clang/lib/Sema/JumpDiagnostics.cpp b/clang/lib/Sema/JumpDiagnostics.cpp
index 6b9eb2a4edd..775fe85740d 100644
--- a/clang/lib/Sema/JumpDiagnostics.cpp
+++ b/clang/lib/Sema/JumpDiagnostics.cpp
@@ -372,13 +372,12 @@ void JumpScopeChecker::BuildScopeInformation(Stmt *S, unsigned &origParentScope)
break;
}
- for (Stmt::child_range CI = S->children(); CI; ++CI) {
+ for (Stmt *SubStmt : S->children()) {
if (SkipFirstSubStmt) {
SkipFirstSubStmt = false;
continue;
}
- Stmt *SubStmt = *CI;
if (!SubStmt) continue;
// Cases, labels, and defaults aren't "scope parents". It's also
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 5737e8338ff..bdfff80c7f2 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -7240,8 +7240,8 @@ void AnalyzeImplicitConversions(Sema &S, Expr *OrigE, SourceLocation CC) {
CC = E->getExprLoc();
BinaryOperator *BO = dyn_cast<BinaryOperator>(E);
bool IsLogicalAndOperator = BO && BO->getOpcode() == BO_LAnd;
- for (Stmt::child_range I = E->children(); I; ++I) {
- Expr *ChildExpr = dyn_cast_or_null<Expr>(*I);
+ for (Stmt *SubStmt : E->children()) {
+ Expr *ChildExpr = dyn_cast_or_null<Expr>(SubStmt);
if (!ChildExpr)
continue;
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 672fc894f1a..0d7cbf45e52 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -73,8 +73,8 @@ namespace {
/// VisitExpr - Visit all of the children of this expression.
bool CheckDefaultArgumentVisitor::VisitExpr(Expr *Node) {
bool IsInvalid = false;
- for (Stmt::child_range I = Node->children(); I; ++I)
- IsInvalid |= Visit(*I);
+ for (Stmt *SubStmt : Node->children())
+ IsInvalid |= Visit(SubStmt);
return IsInvalid;
}
@@ -1091,9 +1091,9 @@ CheckConstexprFunctionStmt(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *S,
break;
if (!Cxx1yLoc.isValid())
Cxx1yLoc = S->getLocStart();
- for (Stmt::child_range Children = S->children(); Children; ++Children)
- if (*Children &&
- !CheckConstexprFunctionStmt(SemaRef, Dcl, *Children, ReturnStmts,
+ for (Stmt *SubStmt : S->children())
+ if (SubStmt &&
+ !CheckConstexprFunctionStmt(SemaRef, Dcl, SubStmt, ReturnStmts,
Cxx1yLoc))
return false;
return true;
@@ -1106,9 +1106,9 @@ CheckConstexprFunctionStmt(Sema &SemaRef, const FunctionDecl *Dcl, Stmt *S,
// mutation, we can reasonably allow them in C++11 as an extension.
if (!Cxx1yLoc.isValid())
Cxx1yLoc = S->getLocStart();
- for (Stmt::child_range Children = S->children(); Children; ++Children)
- if (*Children &&
- !CheckConstexprFunctionStmt(SemaRef, Dcl, *Children, ReturnStmts,
+ for (Stmt *SubStmt : S->children())
+ if (SubStmt &&
+ !CheckConstexprFunctionStmt(SemaRef, Dcl, SubStmt, ReturnStmts,
Cxx1yLoc))
return false;
return true;
@@ -12887,8 +12887,7 @@ void Sema::SetDeclDefaulted(Decl *Dcl, SourceLocation DefaultLoc) {
}
static void SearchForReturnInStmt(Sema &Self, Stmt *S) {
- for (Stmt::child_range CI = S->children(); CI; ++CI) {
- Stmt *SubStmt = *CI;
+ for (Stmt *SubStmt : S->children()) {
if (!SubStmt)
continue;
if (isa<ReturnStmt>(SubStmt))
diff --git a/clang/lib/Sema/SemaExceptionSpec.cpp b/clang/lib/Sema/SemaExceptionSpec.cpp
index f3bcf76a21b..2e3e63e00a3 100644
--- a/clang/lib/Sema/SemaExceptionSpec.cpp
+++ b/clang/lib/Sema/SemaExceptionSpec.cpp
@@ -837,11 +837,13 @@ bool Sema::CheckOverridingFunctionExceptionSpec(const CXXMethodDecl *New,
New->getLocation());
}
-static CanThrowResult canSubExprsThrow(Sema &S, const Expr *CE) {
- Expr *E = const_cast<Expr*>(CE);
+static CanThrowResult canSubExprsThrow(Sema &S, const Expr *E) {
CanThrowResult R = CT_Cannot;
- for (Expr::child_range I = E->children(); I && R != CT_Can; ++I)
- R = mergeCanThrow(R, S.canThrow(cast<Expr>(*I)));
+ for (const Stmt *SubStmt : E->children()) {
+ R = mergeCanThrow(R, S.canThrow(cast<Expr>(SubStmt)));
+ if (R == CT_Can)
+ break;
+ }
return R;
}
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 7286301fe6e..867cb9f3c83 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -3344,8 +3344,7 @@ StmtResult Sema::ActOnOpenMPSectionsDirective(ArrayRef<OMPClause *> Clauses,
return StmtError();
// All associated statements must be '#pragma omp section' except for
// the first one.
- for (++S; S; ++S) {
- auto SectionStmt = *S;
+ for (Stmt *SectionStmt : ++S) {
if (!SectionStmt || !isa<OMPSectionDirective>(SectionStmt)) {
if (SectionStmt)
Diag(SectionStmt->getLocStart(),
@@ -3503,8 +3502,7 @@ Sema::ActOnOpenMPParallelSectionsDirective(ArrayRef<OMPClause *> Clauses,
return StmtError();
// All associated statements must be '#pragma omp section' except for
// the first one.
- for (++S; S; ++S) {
- auto SectionStmt = *S;
+ for (Stmt *SectionStmt : ++S) {
if (!SectionStmt || !isa<OMPSectionDirective>(SectionStmt)) {
if (SectionStmt)
Diag(SectionStmt->getLocStart(),
diff --git a/clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp b/clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
index 0bcebf6e774..a71def23c0b 100644
--- a/clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/DirectIvarAssignment.cpp
@@ -78,9 +78,9 @@ class DirectIvarAssignment :
void VisitBinaryOperator(const BinaryOperator *BO);
void VisitChildren(const Stmt *S) {
- for (Stmt::const_child_range I = S->children(); I; ++I)
- if (*I)
- this->Visit(*I);
+ for (const Stmt *Child : S->children())
+ if (Child)
+ this->Visit(Child);
}
};
diff --git a/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
index 02c12095b5a..3df5fa034a4 100644
--- a/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/IvarInvalidationChecker.cpp
@@ -167,9 +167,9 @@ class IvarInvalidationCheckerImpl {
void VisitObjCMessageExpr(const ObjCMessageExpr *ME);
void VisitChildren(const Stmt *S) {
- for (Stmt::const_child_range I = S->children(); I; ++I) {
- if (*I)
- this->Visit(*I);
+ for (const Stmt *Child : S->children()) {
+ if (Child)
+ this->Visit(Child);
if (CalledAnotherInvalidationMethod)
return;
}
OpenPOWER on IntegriCloud