]> granicus.if.org Git - clang/commitdiff
[ASTDump] NFC: Use `const auto` in cxx_range_for loops
authorStephen Kelly <steveire@gmail.com>
Sat, 19 Jan 2019 09:57:51 +0000 (09:57 +0000)
committerStephen Kelly <steveire@gmail.com>
Sat, 19 Jan 2019 09:57:51 +0000 (09:57 +0000)
This is coming up a lot in reviews. Better just to do them all at once.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@351646 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/ASTDumper.cpp

index fc33ff331bbca17afe1b2b89ae64f253201f9f0e..4b61c30a21ed356ad6d08e9a8c3d91cb32953020 100644 (file)
@@ -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 DeclContext *DC) {
   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(const ObjCTypeParamList *typeParams) {
   if (!typeParams)
     return;
 
-  for (auto typeParam : *typeParams) {
+  for (const auto &typeParam : *typeParams) {
     dumpDecl(typeParam);
   }
 }
@@ -555,7 +555,7 @@ void ASTDumper::VisitIndirectFieldDecl(const IndirectFieldDecl *D) {
   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 VarDecl *D) {
 
 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 CapturedDecl *D) {
 //===----------------------------------------------------------------------===//
 
 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::VisitOMPDeclareReductionDecl(const OMPDeclareReductionDecl *D) {
 }
 
 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::dumpTemplateDeclSpecialization(const SpecializationDecl *D,
                                                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 TemplateDecl *D, bool DumpExplicitInst) {
 
   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::VisitObjCCategoryImplDecl(const ObjCCategoryImplDecl *D) {
 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(const ObjCInterfaceDecl *D) {
   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 BlockDecl *D) {
   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 CapturedStmt *Node) {
 void ASTDumper::Visit(const OMPClause *C) {
   dumpChild([=] {
     NodeDumper.Visit(C);
-    for (auto *S : C->children())
+    for (const auto *S : C->children())
       dumpStmt(S);
   });
 }