Index: lld/COFF/Chunks.cpp =================================================================== --- lld/COFF/Chunks.cpp +++ lld/COFF/Chunks.cpp @@ -658,8 +658,7 @@ } // sizeInBits is used to initialize the Flags field; currently no // other flags are defined. - res.emplace_back( - RuntimePseudoReloc(target, this, rel.VirtualAddress, sizeInBits)); + res.emplace_back(target, this, rel.VirtualAddress, sizeInBits); } } Index: lld/COFF/Driver.cpp =================================================================== --- lld/COFF/Driver.cpp +++ lld/COFF/Driver.cpp @@ -1506,7 +1506,7 @@ } // Construct search path list. - searchPaths.push_back(""); + searchPaths.emplace_back(""); for (auto *arg : args.filtered(OPT_libpath)) searchPaths.push_back(arg->getValue()); detectWinSysRoot(args); Index: lld/COFF/DriverUtils.cpp =================================================================== --- lld/COFF/DriverUtils.cpp +++ lld/COFF/DriverUtils.cpp @@ -347,9 +347,7 @@ } } - TemporaryFile(TemporaryFile &&obj) { - std::swap(path, obj.path); - } + TemporaryFile(TemporaryFile &&obj) noexcept { std::swap(path, obj.path); } ~TemporaryFile() { if (path.empty()) @@ -869,7 +867,7 @@ ctx.config.argv = {argv[0]}; for (opt::Arg *arg : args) { if (arg->getOption().getKind() != opt::Option::InputClass) { - ctx.config.argv.push_back(args.getArgString(arg->getIndex())); + ctx.config.argv.emplace_back(args.getArgString(arg->getIndex())); } } Index: lld/COFF/MinGW.cpp =================================================================== --- lld/COFF/MinGW.cpp +++ lld/COFF/MinGW.cpp @@ -267,8 +267,8 @@ // Update pointers in input files. parallelForEach(ctx.objFileInstances, [&](ObjFile *file) { MutableArrayRef syms = file->getMutableSymbols(); - for (size_t i = 0, e = syms.size(); i != e; ++i) - if (Symbol *s = map.lookup(syms[i])) - syms[i] = s; + for (auto &sym : syms) + if (Symbol *s = map.lookup(sym)) + sym = s; }); } Index: lld/COFF/Writer.cpp =================================================================== --- lld/COFF/Writer.cpp +++ lld/COFF/Writer.cpp @@ -488,7 +488,7 @@ uint32_t &thunkSymbolIndex = insertion.first->second; if (insertion.second) thunkSymbolIndex = file->addRangeThunkSymbol(thunk); - relocReplacements.push_back({j, thunkSymbolIndex}); + relocReplacements.emplace_back(j, thunkSymbolIndex); } // Get a writable copy of this section's relocations so they can be @@ -531,8 +531,7 @@ continue; ArrayRef relocs = sc->getRelocs(); - for (size_t j = 0, e = relocs.size(); j < e; ++j) { - const coff_relocation &rel = relocs[j]; + for (const coff_relocation &rel : relocs) { Symbol *relocTarget = sc->file->getSymbol(rel.SymbolTableIndex); Defined *sym = dyn_cast_or_null(relocTarget); @@ -1034,13 +1033,13 @@ // allowing a debugger to match a PDB and an executable. So we need it even // if we're ultimately not going to write CodeView data to the PDB. buildId = make(ctx); - debugRecords.push_back({COFF::IMAGE_DEBUG_TYPE_CODEVIEW, buildId}); + debugRecords.emplace_back(COFF::IMAGE_DEBUG_TYPE_CODEVIEW, buildId); } if (config->cetCompat) { - debugRecords.push_back({COFF::IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS, - make( - IMAGE_DLL_CHARACTERISTICS_EX_CET_COMPAT)}); + debugRecords.emplace_back(COFF::IMAGE_DEBUG_TYPE_EX_DLLCHARACTERISTICS, + make( + IMAGE_DLL_CHARACTERISTICS_EX_CET_COMPAT)); } // Align and add each chunk referenced by the debug data directory. Index: lld/ELF/InputFiles.cpp =================================================================== --- lld/ELF/InputFiles.cpp +++ lld/ELF/InputFiles.cpp @@ -1706,9 +1706,9 @@ // user programs can access blobs by name. Non-alphanumeric // characters in a filename are replaced with underscore. std::string s = "_binary_" + mb.getBufferIdentifier().str(); - for (size_t i = 0; i < s.size(); ++i) - if (!isAlnum(s[i])) - s[i] = '_'; + for (char &c : s) + if (!isAlnum(c)) + c = '_'; llvm::StringSaver &saver = lld::saver(); Index: lld/ELF/MapFile.cpp =================================================================== --- lld/ELF/MapFile.cpp +++ lld/ELF/MapFile.cpp @@ -157,7 +157,7 @@ os << right_justify("VMA", w) << ' ' << right_justify("LMA", w) << " Size Align Out In Symbol\n"; - OutputSection* osec = nullptr; + OutputSection *osec = nullptr; for (SectionCommand *cmd : script->sectionCommands) { if (auto *assign = dyn_cast(cmd)) { if (assign->provide && !assign->sym) Index: lld/ELF/OutputSections.cpp =================================================================== --- lld/ELF/OutputSections.cpp +++ lld/ELF/OutputSections.cpp @@ -242,7 +242,7 @@ llvm::function_ref order) { std::vector> v; for (InputSection *s : in) - v.push_back({order(s), s}); + v.emplace_back(order(s), s); llvm::stable_sort(v, less_first()); for (size_t i = 0; i < v.size(); ++i) Index: lld/MachO/Arch/ARM64.cpp =================================================================== --- lld/MachO/Arch/ARM64.cpp +++ lld/MachO/Arch/ARM64.cpp @@ -139,14 +139,14 @@ thunk->align = 4; thunk->data = {reinterpret_cast(thunkCode), sizeof(thunkCode)}; - thunk->relocs.push_back({/*type=*/ARM64_RELOC_PAGEOFF12, - /*pcrel=*/false, /*length=*/2, - /*offset=*/4, /*addend=*/0, - /*referent=*/funcSym}); - thunk->relocs.push_back({/*type=*/ARM64_RELOC_PAGE21, - /*pcrel=*/true, /*length=*/2, - /*offset=*/0, /*addend=*/0, - /*referent=*/funcSym}); + thunk->relocs.emplace_back(/*type=*/ARM64_RELOC_PAGEOFF12, + /*pcrel=*/false, /*length=*/2, + /*offset=*/4, /*addend=*/0, + /*referent=*/funcSym); + thunk->relocs.emplace_back(/*type=*/ARM64_RELOC_PAGE21, + /*pcrel=*/true, /*length=*/2, + /*offset=*/0, /*addend=*/0, + /*referent=*/funcSym); } ARM64::ARM64() : ARM64Common(LP64()) { Index: lld/MachO/SyntheticSections.h =================================================================== --- lld/MachO/SyntheticSections.h +++ lld/MachO/SyntheticSections.h @@ -162,7 +162,7 @@ void addEntry(const InputSection *isec, uint64_t offset) { if (config->isPic) - locations.push_back({isec, offset}); + locations.emplace_back(isec, offset); } private: @@ -174,7 +174,7 @@ int64_t addend; Location target; BindingEntry(int64_t addend, Location target) - : addend(addend), target(std::move(target)) {} + : addend(addend), target(target) {} }; template