diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -8203,7 +8203,7 @@ if (!CXXRD->hasDefinition() || !VisitBasesAndFields) return false; - for (auto B : CXXRD->bases()) + for (const auto &B : CXXRD->bases()) if (hasTemplateSpecializationInEncodedString(B.getType().getTypePtr(), true)) return true; diff --git a/clang/lib/AST/ComputeDependence.cpp b/clang/lib/AST/ComputeDependence.cpp --- a/clang/lib/AST/ComputeDependence.cpp +++ b/clang/lib/AST/ComputeDependence.cpp @@ -760,7 +760,7 @@ D |= getDependenceInExpr(E->getNameInfo()); if (auto *Q = E->getQualifier()) D |= toExprDependence(Q->getDependence()); - for (auto A : E->template_arguments()) + for (const auto &A : E->template_arguments()) D |= toExprDependence(A.getArgument().getDependence()); return D; } @@ -813,7 +813,7 @@ if (auto *Q = E->getQualifier()) D |= toExprDependence(Q->getDependence()); D |= getDependenceInExpr(E->getMemberNameInfo()); - for (auto A : E->template_arguments()) + for (const auto &A : E->template_arguments()) D |= toExprDependence(A.getArgument().getDependence()); return D; } diff --git a/clang/lib/ASTMatchers/Dynamic/Marshallers.h b/clang/lib/ASTMatchers/Dynamic/Marshallers.h --- a/clang/lib/ASTMatchers/Dynamic/Marshallers.h +++ b/clang/lib/ASTMatchers/Dynamic/Marshallers.h @@ -1008,7 +1008,7 @@ Diagnostics *) const override { std::vector NodeKinds; - for (auto Arg : Args) { + for (const auto &Arg : Args) { if (!Arg.Value.isNodeKind()) return {}; NodeKinds.push_back(Arg.Value.getNodeKind()); diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp --- a/clang/lib/CodeGen/CGVTables.cpp +++ b/clang/lib/CodeGen/CGVTables.cpp @@ -1269,13 +1269,13 @@ else TypeVis = llvm::GlobalObject::VCallVisibilityPublic; - for (auto B : RD->bases()) + for (const auto &B : RD->bases()) if (B.getType()->getAsCXXRecordDecl()->isDynamicClass()) TypeVis = std::min( TypeVis, GetVCallVisibilityLevel(B.getType()->getAsCXXRecordDecl(), Visited)); - for (auto B : RD->vbases()) + for (const auto &B : RD->vbases()) if (B.getType()->getAsCXXRecordDecl()->isDynamicClass()) TypeVis = std::min( TypeVis, diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -3971,7 +3971,7 @@ } llvm::SmallPtrSet UninitializedBaseClasses; - for (auto I : RD->bases()) + for (const auto &I : RD->bases()) UninitializedBaseClasses.insert(I.getType().getCanonicalType()); if (UninitializedFields.empty() && UninitializedBaseClasses.empty()) diff --git a/clang/utils/TableGen/ClangAttrEmitter.cpp b/clang/utils/TableGen/ClangAttrEmitter.cpp --- a/clang/utils/TableGen/ClangAttrEmitter.cpp +++ b/clang/utils/TableGen/ClangAttrEmitter.cpp @@ -4259,7 +4259,7 @@ // Generate all of the custom appertainsTo functions that the attributes // will be using. - for (auto I : Attrs) { + for (const auto &I : Attrs) { const Record &Attr = *I.second; if (Attr.isValueUnset("Subjects")) continue;