diff options
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r-- | clang/lib/Sema/AnalysisBasedWarnings.cpp | 9 | ||||
-rw-r--r-- | clang/lib/Sema/JumpDiagnostics.cpp | 3 | ||||
-rw-r--r-- | clang/lib/Sema/SemaChecking.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 19 | ||||
-rw-r--r-- | clang/lib/Sema/SemaExceptionSpec.cpp | 10 | ||||
-rw-r--r-- | clang/lib/Sema/SemaOpenMP.cpp | 6 |
6 files changed, 24 insertions, 27 deletions
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(), |