Index: lld/COFF/DriverUtils.cpp =================================================================== --- lld/COFF/DriverUtils.cpp +++ lld/COFF/DriverUtils.cpp @@ -76,8 +76,7 @@ // Parses a string in the form of "[,]". void parseNumbers(StringRef arg, uint64_t *addr, uint64_t *size) { - StringRef s1, s2; - std::tie(s1, s2) = arg.split(','); + auto [s1, s2] = arg.split(','); if (s1.getAsInteger(0, *addr)) fatal("invalid number: " + s1); if (size && !s2.empty() && s2.getAsInteger(0, *size)) @@ -87,8 +86,7 @@ // Parses a string in the form of "[.]". // If second number is not present, Minor is set to 0. void parseVersion(StringRef arg, uint32_t *major, uint32_t *minor) { - StringRef s1, s2; - std::tie(s1, s2) = arg.split('.'); + auto [s1, s2] = arg.split('.'); if (s1.getAsInteger(10, *major)) fatal("invalid number: " + s1); *minor = 0; @@ -120,8 +118,7 @@ // Parses a string in the form of "[,[.]]". void parseSubsystem(StringRef arg, WindowsSubsystem *sys, uint32_t *major, uint32_t *minor, bool *gotVersion) { - StringRef sysStr, ver; - std::tie(sysStr, ver) = arg.split(','); + auto [sysStr, ver] = arg.split(','); std::string sysStrLower = sysStr.lower(); *sys = StringSwitch(sysStrLower) .Case("boot_application", IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION) @@ -146,8 +143,7 @@ // Parse a string of the form of "=". // Results are directly written to Config. void parseAlternateName(StringRef s) { - StringRef from, to; - std::tie(from, to) = s.split('='); + auto [from, to] = s.split('='); if (from.empty() || to.empty()) fatal("/alternatename: invalid argument: " + s); auto it = config->alternateNames.find(from); @@ -159,8 +155,7 @@ // Parse a string of the form of "=". // Results are directly written to Config. void parseMerge(StringRef s) { - StringRef from, to; - std::tie(from, to) = s.split('='); + auto [from, to] = s.split('='); if (from.empty() || to.empty()) fatal("/merge: invalid argument: " + s); if (from == ".rsrc" || to == ".rsrc") @@ -224,8 +219,7 @@ // Parses /section option argument. void parseSection(StringRef s) { - StringRef name, attrs; - std::tie(name, attrs) = s.split(','); + auto [name, attrs] = s.split(','); if (name.empty() || attrs.empty()) fatal("/section: invalid argument: " + s); config->section[name] = parseSectionAttributes(attrs); @@ -233,8 +227,7 @@ // Parses /aligncomm option argument. void parseAligncomm(StringRef s) { - StringRef name, align; - std::tie(name, align) = s.split(','); + auto [name, align] = s.split(','); if (name.empty() || align.empty()) { error("/aligncomm: invalid argument: " + s); return; @@ -318,8 +311,7 @@ // Results are directly written to Config. void parseSwaprun(StringRef arg) { do { - StringRef swaprun, newArg; - std::tie(swaprun, newArg) = arg.split(','); + auto [swaprun, newArg] = arg.split(','); if (swaprun.equals_insensitive("cd")) config->swaprunCD = true; else if (swaprun.equals_insensitive("net")) @@ -561,8 +553,7 @@ goto err; if (e.name.contains('=')) { - StringRef x, y; - std::tie(x, y) = e.name.split("="); + auto [x, y] = e.name.split("="); // If "=.". if (y.contains(".")) { @@ -716,8 +707,7 @@ // Parses a string in the form of "key=value" and check // if value matches previous values for the same key. void checkFailIfMismatch(StringRef arg, InputFile *source) { - StringRef k, v; - std::tie(k, v) = arg.split('='); + auto [k, v] = arg.split('='); if (k.empty() || v.empty()) fatal("/failifmismatch: invalid argument: " + arg); std::pair existing = config->mustMatch[k]; Index: lld/COFF/SymbolTable.cpp =================================================================== --- lld/COFF/SymbolTable.cpp +++ lld/COFF/SymbolTable.cpp @@ -245,9 +245,7 @@ const size_t maxUndefReferences = 3; size_t numDisplayedRefs = 0, numRefs = 0; for (const UndefinedDiag::File &ref : undefDiag.files) { - std::vector symbolLocations; - size_t totalLocations = 0; - std::tie(symbolLocations, totalLocations) = getSymbolLocations( + auto [symbolLocations, totalLocations] = getSymbolLocations( ref.file, ref.symIndex, maxUndefReferences - numDisplayedRefs); numRefs += totalLocations; @@ -543,9 +541,7 @@ Symbol *SymbolTable::addUndefined(StringRef name, InputFile *f, bool isWeakAlias) { - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(name, f); + auto [s, wasInserted] = insert(name, f); if (wasInserted || (s->isLazy() && isWeakAlias)) { replaceSymbol(s, name); return s; @@ -557,9 +553,7 @@ void SymbolTable::addLazyArchive(ArchiveFile *f, const Archive::Symbol &sym) { StringRef name = sym.getName(); - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(name); + auto [s, wasInserted] = insert(name); if (wasInserted) { replaceSymbol(s, f, sym); return; @@ -573,9 +567,7 @@ void SymbolTable::addLazyObject(InputFile *f, StringRef n) { assert(f->lazy); - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(n, f); + auto [s, wasInserted] = insert(n, f); if (wasInserted) { replaceSymbol(s, f, n); return; @@ -590,9 +582,7 @@ void SymbolTable::addLazyDLLSymbol(DLLFile *f, DLLFile::Symbol *sym, StringRef n) { - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(n); + auto [s, wasInserted] = insert(n); if (wasInserted) { replaceSymbol(s, f, sym, n); return; @@ -672,9 +662,7 @@ } Symbol *SymbolTable::addAbsolute(StringRef n, COFFSymbolRef sym) { - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(n, nullptr); + auto [s, wasInserted] = insert(n, nullptr); s->isUsedInRegularObj = true; if (wasInserted || isa(s) || s->isLazy()) replaceSymbol(s, n, sym); @@ -687,9 +675,7 @@ } Symbol *SymbolTable::addAbsolute(StringRef n, uint64_t va) { - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(n, nullptr); + auto [s, wasInserted] = insert(n, nullptr); s->isUsedInRegularObj = true; if (wasInserted || isa(s) || s->isLazy()) replaceSymbol(s, n, va); @@ -702,9 +688,7 @@ } Symbol *SymbolTable::addSynthetic(StringRef n, Chunk *c) { - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(n, nullptr); + auto [s, wasInserted] = insert(n, nullptr); s->isUsedInRegularObj = true; if (wasInserted || isa(s) || s->isLazy()) replaceSymbol(s, n, c); @@ -716,9 +700,7 @@ Symbol *SymbolTable::addRegular(InputFile *f, StringRef n, const coff_symbol_generic *sym, SectionChunk *c, uint32_t sectionOffset) { - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(n, f); + auto [s, wasInserted] = insert(n, f); if (wasInserted || !isa(s)) replaceSymbol(s, f, n, /*IsCOMDAT*/ false, /*IsExternal*/ true, sym, c); @@ -730,9 +712,7 @@ std::pair SymbolTable::addComdat(InputFile *f, StringRef n, const coff_symbol_generic *sym) { - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(n, f); + auto [s, wasInserted] = insert(n, f); if (wasInserted || !isa(s)) { replaceSymbol(s, f, n, /*IsCOMDAT*/ true, /*IsExternal*/ true, sym, nullptr); @@ -746,9 +726,7 @@ Symbol *SymbolTable::addCommon(InputFile *f, StringRef n, uint64_t size, const coff_symbol_generic *sym, CommonChunk *c) { - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(n, f); + auto [s, wasInserted] = insert(n, f); if (wasInserted || !isa(s)) replaceSymbol(s, f, n, size, sym, c); else if (auto *dc = dyn_cast(s)) @@ -758,9 +736,7 @@ } Symbol *SymbolTable::addImportData(StringRef n, ImportFile *f) { - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(n, nullptr); + auto [s, wasInserted] = insert(n, nullptr); s->isUsedInRegularObj = true; if (wasInserted || isa(s) || s->isLazy()) { replaceSymbol(s, n, f); @@ -773,9 +749,7 @@ Symbol *SymbolTable::addImportThunk(StringRef name, DefinedImportData *id, uint16_t machine) { - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(name, nullptr); + auto [s, wasInserted] = insert(name, nullptr); s->isUsedInRegularObj = true; if (wasInserted || isa(s) || s->isLazy()) { replaceSymbol(s, name, id, machine); Index: lld/COFF/Writer.cpp =================================================================== --- lld/COFF/Writer.cpp +++ lld/COFF/Writer.cpp @@ -451,11 +451,8 @@ if (isInRange(rel.Type, s, p, margin)) continue; - // If the target isn't in range, hook it up to an existing or new - // thunk. - Defined *thunk; - bool wasNew; - std::tie(thunk, wasNew) = getThunk(lastThunks, sym, p, rel.Type, margin); + // If the target isn't in range, hook it up to an existing or new thunk. + auto [thunk, wasNew] = getThunk(lastThunks, sym, p, rel.Type, margin); if (wasNew) { Chunk *thunkChunk = thunk->getChunk(); thunkChunk->setRVA(