r351646 - [ASTDump] NFC: Use `const auto` in cxx_range_for loops
Stephen Kelly via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 19 01:57:51 PST 2019
Author: steveire
Date: Sat Jan 19 01:57:51 2019
New Revision: 351646
URL: http://llvm.org/viewvc/llvm-project?rev=351646&view=rev
Log:
[ASTDump] NFC: Use `const auto` in cxx_range_for loops
This is coming up a lot in reviews. Better just to do them all at once.
Modified:
cfe/trunk/lib/AST/ASTDumper.cpp
Modified: cfe/trunk/lib/AST/ASTDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTDumper.cpp?rev=351646&r1=351645&r2=351646&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTDumper.cpp (original)
+++ cfe/trunk/lib/AST/ASTDumper.cpp Sat Jan 19 01:57:51 2019
@@ -161,7 +161,7 @@ namespace {
}
void VisitFunctionProtoType(const FunctionProtoType *T) {
VisitFunctionType(T);
- for (QualType PT : T->getParamTypes())
+ for (const QualType &PT : T->getParamTypes())
dumpTypeAsChild(PT);
}
void VisitTypeOfExprType(const TypeOfExprType *T) {
@@ -186,7 +186,7 @@ namespace {
dumpTemplateArgument(T->getArgumentPack());
}
void VisitTemplateSpecializationType(const TemplateSpecializationType *T) {
- for (auto &Arg : *T)
+ for (const auto &Arg : *T)
dumpTemplateArgument(Arg);
if (T->isTypeAlias())
dumpTypeAsChild(T->getAliasedType());
@@ -357,7 +357,7 @@ void ASTDumper::dumpDeclContext(const De
if (!DC)
return;
- for (auto *D : (Deserialize ? DC->decls() : DC->noload_decls()))
+ for (const auto *D : (Deserialize ? DC->decls() : DC->noload_decls()))
dumpDecl(D);
}
@@ -478,7 +478,7 @@ void ASTDumper::dumpObjCTypeParamList(co
if (!typeParams)
return;
- for (auto typeParam : *typeParams) {
+ for (const auto &typeParam : *typeParams) {
dumpDecl(typeParam);
}
}
@@ -555,7 +555,7 @@ void ASTDumper::VisitIndirectFieldDecl(c
NodeDumper.dumpName(D);
NodeDumper.dumpType(D->getType());
- for (auto *Child : D->chain())
+ for (const auto *Child : D->chain())
NodeDumper.dumpDeclRef(Child);
}
@@ -688,14 +688,14 @@ void ASTDumper::VisitVarDecl(const VarDe
void ASTDumper::VisitDecompositionDecl(const DecompositionDecl *D) {
VisitVarDecl(D);
- for (auto *B : D->bindings())
+ for (const auto *B : D->bindings())
dumpDecl(B);
}
void ASTDumper::VisitBindingDecl(const BindingDecl *D) {
NodeDumper.dumpName(D);
NodeDumper.dumpType(D->getType());
- if (auto *E = D->getBinding())
+ if (const auto *E = D->getBinding())
dumpStmt(E);
}
@@ -736,7 +736,7 @@ void ASTDumper::VisitCapturedDecl(const
//===----------------------------------------------------------------------===//
void ASTDumper::VisitOMPThreadPrivateDecl(const OMPThreadPrivateDecl *D) {
- for (auto *E : D->varlists())
+ for (const auto *E : D->varlists())
dumpStmt(E);
}
@@ -766,7 +766,7 @@ void ASTDumper::VisitOMPDeclareReduction
}
void ASTDumper::VisitOMPRequiresDecl(const OMPRequiresDecl *D) {
- for (auto *C : D->clauselists()) {
+ for (const auto *C : D->clauselists()) {
dumpChild([=] {
if (!C) {
ColorScope Color(OS, ShowColors, NullColor);
@@ -974,7 +974,7 @@ void ASTDumper::dumpTemplateDeclSpeciali
bool DumpExplicitInst,
bool DumpRefOnly) {
bool DumpedAny = false;
- for (auto *RedeclWithBadType : D->redecls()) {
+ for (const auto *RedeclWithBadType : D->redecls()) {
// FIXME: The redecls() range sometimes has elements of a less-specific
// type. (In particular, ClassTemplateSpecializationDecl::redecls() gives
// us TagDecls, and should give CXXRecordDecls).
@@ -1018,7 +1018,7 @@ void ASTDumper::dumpTemplateDecl(const T
dumpDecl(D->getTemplatedDecl());
- for (auto *Child : D->specializations())
+ for (const auto *Child : D->specializations())
dumpTemplateDeclSpecialization(Child, DumpExplicitInst,
!D->isCanonicalDecl());
}
@@ -1280,7 +1280,7 @@ void ASTDumper::VisitObjCCategoryImplDec
void ASTDumper::VisitObjCProtocolDecl(const ObjCProtocolDecl *D) {
NodeDumper.dumpName(D);
- for (auto *Child : D->protocols())
+ for (const auto *Child : D->protocols())
NodeDumper.dumpDeclRef(Child);
}
@@ -1289,7 +1289,7 @@ void ASTDumper::VisitObjCInterfaceDecl(c
NodeDumper.dumpDeclRef(D->getSuperClass(), "super");
NodeDumper.dumpDeclRef(D->getImplementation());
- for (auto *Child : D->protocols())
+ for (const auto *Child : D->protocols())
NodeDumper.dumpDeclRef(Child);
dumpObjCTypeParamList(D->getTypeParamListAsWritten());
}
@@ -1374,7 +1374,7 @@ void ASTDumper::VisitBlockDecl(const Blo
if (D->capturesCXXThis())
OS << " captures_this";
- for (auto I : D->parameters())
+ for (const auto &I : D->parameters())
dumpDecl(I);
for (const auto &I : D->captures())
@@ -1435,7 +1435,7 @@ void ASTDumper::VisitCapturedStmt(const
void ASTDumper::Visit(const OMPClause *C) {
dumpChild([=] {
NodeDumper.Visit(C);
- for (auto *S : C->children())
+ for (const auto *S : C->children())
dumpStmt(S);
});
}
More information about the cfe-commits
mailing list