Skip to content

Commit 8805f67

Browse files
committed
[ASTDump] NFC: Convert iterative loops to cxx_range_for
This is coming up a lot in reviews. Better just to change them all at once. llvm-svn: 351647
1 parent aaebc5f commit 8805f67

File tree

1 file changed

+14
-24
lines changed

1 file changed

+14
-24
lines changed

clang/lib/AST/ASTDumper.cpp

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -442,15 +442,14 @@ void ASTDumper::dumpTemplateParameters(const TemplateParameterList *TPL) {
442442
if (!TPL)
443443
return;
444444

445-
for (TemplateParameterList::const_iterator I = TPL->begin(), E = TPL->end();
446-
I != E; ++I)
447-
dumpDecl(*I);
445+
for (const auto &TP : *TPL)
446+
dumpDecl(TP);
448447
}
449448

450449
void ASTDumper::dumpTemplateArgumentListInfo(
451450
const TemplateArgumentListInfo &TALI) {
452-
for (unsigned i = 0, e = TALI.size(); i < e; ++i)
453-
dumpTemplateArgumentLoc(TALI[i]);
451+
for (const auto &TA : TALI.arguments())
452+
dumpTemplateArgumentLoc(TA);
454453
}
455454

456455
void ASTDumper::dumpTemplateArgumentLoc(const TemplateArgumentLoc &A,
@@ -495,9 +494,8 @@ void ASTDumper::dumpDecl(const Decl *D) {
495494

496495
ConstDeclVisitor<ASTDumper>::Visit(D);
497496

498-
for (Decl::attr_iterator I = D->attr_begin(), E = D->attr_end(); I != E;
499-
++I)
500-
dumpAttr(*I);
497+
for (const auto &A : D->attrs())
498+
dumpAttr(A);
501499

502500
if (const FullComment *Comment =
503501
D->getASTContext().getLocalCommentForDeclUncached(D))
@@ -1264,10 +1262,8 @@ void ASTDumper::VisitObjCCategoryDecl(const ObjCCategoryDecl *D) {
12641262
NodeDumper.dumpName(D);
12651263
NodeDumper.dumpDeclRef(D->getClassInterface());
12661264
NodeDumper.dumpDeclRef(D->getImplementation());
1267-
for (ObjCCategoryDecl::protocol_iterator I = D->protocol_begin(),
1268-
E = D->protocol_end();
1269-
I != E; ++I)
1270-
NodeDumper.dumpDeclRef(*I);
1265+
for (const auto *P : D->protocols())
1266+
NodeDumper.dumpDeclRef(P);
12711267
dumpObjCTypeParamList(D->getTypeParamList());
12721268
}
12731269

@@ -1298,10 +1294,8 @@ void ASTDumper::VisitObjCImplementationDecl(const ObjCImplementationDecl *D) {
12981294
NodeDumper.dumpName(D);
12991295
NodeDumper.dumpDeclRef(D->getSuperClass(), "super");
13001296
NodeDumper.dumpDeclRef(D->getClassInterface());
1301-
for (ObjCImplementationDecl::init_const_iterator I = D->init_begin(),
1302-
E = D->init_end();
1303-
I != E; ++I)
1304-
dumpCXXCtorInitializer(*I);
1297+
for (const auto &I : D->inits())
1298+
dumpCXXCtorInitializer(I);
13051299
}
13061300

13071301
void ASTDumper::VisitObjCCompatibleAliasDecl(const ObjCCompatibleAliasDecl *D) {
@@ -1407,17 +1401,13 @@ void ASTDumper::dumpStmt(const Stmt *S, StringRef Label) {
14071401
}
14081402

14091403
void ASTDumper::VisitDeclStmt(const DeclStmt *Node) {
1410-
for (DeclStmt::const_decl_iterator I = Node->decl_begin(),
1411-
E = Node->decl_end();
1412-
I != E; ++I)
1413-
dumpDecl(*I);
1404+
for (const auto &D : Node->decls())
1405+
dumpDecl(D);
14141406
}
14151407

14161408
void ASTDumper::VisitAttributedStmt(const AttributedStmt *Node) {
1417-
for (ArrayRef<const Attr *>::iterator I = Node->getAttrs().begin(),
1418-
E = Node->getAttrs().end();
1419-
I != E; ++I)
1420-
dumpAttr(*I);
1409+
for (const auto *A : Node->getAttrs())
1410+
dumpAttr(A);
14211411
}
14221412

14231413
void ASTDumper::VisitCXXCatchStmt(const CXXCatchStmt *Node) {

0 commit comments

Comments
 (0)