diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 05b3ac4305ac..7ee8e1fc8a22 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -458,8 +458,8 @@ TargetMachine *EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) { BackendArgs.push_back("-limit-float-precision"); BackendArgs.push_back(CodeGenOpts.LimitFloatPrecision.c_str()); } - for (unsigned i = 0, e = CodeGenOpts.BackendOptions.size(); i != e; ++i) - BackendArgs.push_back(CodeGenOpts.BackendOptions[i].c_str()); + for (const std::string &BackendOption : CodeGenOpts.BackendOptions) + BackendArgs.push_back(BackendOption.c_str()); BackendArgs.push_back(nullptr); llvm::cl::ParseCommandLineOptions(BackendArgs.size() - 1, BackendArgs.data()); diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp index 3f5c7a49c172..42cfd36e845e 100644 --- a/clang/lib/CodeGen/CGVTables.cpp +++ b/clang/lib/CodeGen/CGVTables.cpp @@ -502,8 +502,8 @@ void CodeGenVTables::EmitThunks(GlobalDecl GD) if (!ThunkInfoVector) return; - for (unsigned I = 0, E = ThunkInfoVector->size(); I != E; ++I) - emitThunk(GD, (*ThunkInfoVector)[I], /*ForVTable=*/false); + for (const ThunkInfo& Thunk : *ThunkInfoVector) + emitThunk(GD, Thunk, /*ForVTable=*/false); } llvm::Constant *CodeGenVTables::CreateVTableInitializer( diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp index 0e7b6d8a71d4..8f5ee6fde0aa 100644 --- a/clang/lib/CodeGen/CodeGenAction.cpp +++ b/clang/lib/CodeGen/CodeGenAction.cpp @@ -333,8 +333,7 @@ void BackendConsumer::InlineAsmDiagHandler2(const llvm::SMDiagnostic &D, DiagnosticBuilder B = Diags.Report(Loc, diag::note_fe_inline_asm_here); // Convert the SMDiagnostic ranges into SourceRange and attach them // to the diagnostic. - for (unsigned i = 0, e = D.getRanges().size(); i != e; ++i) { - std::pair Range = D.getRanges()[i]; + for (const std::pair &Range : D.getRanges()) { unsigned Column = D.getColumnNo(); B << SourceRange(Loc.getLocWithOffset(Range.first - Column), Loc.getLocWithOffset(Range.second - Column)); diff --git a/clang/lib/CodeGen/ItaniumCXXABI.cpp b/clang/lib/CodeGen/ItaniumCXXABI.cpp index 0b65088e6196..cb506c32cbab 100644 --- a/clang/lib/CodeGen/ItaniumCXXABI.cpp +++ b/clang/lib/CodeGen/ItaniumCXXABI.cpp @@ -2079,9 +2079,9 @@ void ItaniumCXXABI::EmitThreadLocalInitFuncs( CodeGenFunction(CGM) .GenerateCXXGlobalInitFunc(InitFunc, CXXThreadLocalInits, Guard); } - for (unsigned I = 0, N = CXXThreadLocals.size(); I != N; ++I) { - const VarDecl *VD = CXXThreadLocals[I].first; - llvm::GlobalVariable *Var = CXXThreadLocals[I].second; + for (auto &I : CXXThreadLocals) { + const VarDecl *VD = I.first; + llvm::GlobalVariable *Var = I.second; // Some targets require that all access to thread local variables go through // the thread wrapper. This means that we cannot attempt to create a thread