From b99da9d255e9182fcf477b32b2cea221f2b54c85 Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Sun, 7 Aug 2022 10:49:26 -0400 Subject: [PATCH] [lld/mac] Use C++17 structured bindings No behavior change. Differential Revision: https://reviews.llvm.org/D131355 --- lld/MachO/MapFile.cpp | 3 +-- lld/MachO/SymbolTable.cpp | 24 ++++++------------------ 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/lld/MachO/MapFile.cpp b/lld/MachO/MapFile.cpp index 974d823a4fab..19eb25fe1eeb 100644 --- a/lld/MachO/MapFile.cpp +++ b/lld/MachO/MapFile.cpp @@ -152,8 +152,7 @@ void macho::writeMapFile() { } // Dump table of symbols - Symbols liveSymbols, deadSymbols; - std::tie(liveSymbols, deadSymbols) = getSymbols(); + auto [liveSymbols, deadSymbols] = getSymbols(); DenseMap liveSymbolStrings = getSymbolStrings(liveSymbols); diff --git a/lld/MachO/SymbolTable.cpp b/lld/MachO/SymbolTable.cpp index 3667a7137291..3f341e146d84 100644 --- a/lld/MachO/SymbolTable.cpp +++ b/lld/MachO/SymbolTable.cpp @@ -51,10 +51,8 @@ Defined *SymbolTable::addDefined(StringRef name, InputFile *file, bool isPrivateExtern, bool isThumb, bool isReferencedDynamically, bool noDeadStrip, bool isWeakDefCanBeHidden) { - Symbol *s; - bool wasInserted; bool overridesWeakDef = false; - std::tie(s, wasInserted) = insert(name, file); + auto [s, wasInserted] = insert(name, file); assert(!isWeakDef || (isa(file) && !isec) || (isa(file) && file == isec->getFile())); @@ -126,9 +124,7 @@ Defined *SymbolTable::aliasDefined(Defined *src, StringRef target) { Symbol *SymbolTable::addUndefined(StringRef name, InputFile *file, bool isWeakRef) { - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(name, file); + auto [s, wasInserted] = insert(name, file); RefState refState = isWeakRef ? RefState::Weak : RefState::Strong; @@ -147,9 +143,7 @@ Symbol *SymbolTable::addUndefined(StringRef name, InputFile *file, Symbol *SymbolTable::addCommon(StringRef name, InputFile *file, uint64_t size, uint32_t align, bool isPrivateExtern) { - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(name, file); + auto [s, wasInserted] = insert(name, file); if (!wasInserted) { if (auto *common = dyn_cast(s)) { @@ -168,9 +162,7 @@ Symbol *SymbolTable::addCommon(StringRef name, InputFile *file, uint64_t size, Symbol *SymbolTable::addDylib(StringRef name, DylibFile *file, bool isWeakDef, bool isTlv) { - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(name, file); + auto [s, wasInserted] = insert(name, file); RefState refState = RefState::Unreferenced; if (!wasInserted) { @@ -203,9 +195,7 @@ Symbol *SymbolTable::addDynamicLookup(StringRef name) { Symbol *SymbolTable::addLazyArchive(StringRef name, ArchiveFile *file, const object::Archive::Symbol &sym) { - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(name, file); + auto [s, wasInserted] = insert(name, file); if (wasInserted) { replaceSymbol(s, file, sym); @@ -223,9 +213,7 @@ Symbol *SymbolTable::addLazyArchive(StringRef name, ArchiveFile *file, } Symbol *SymbolTable::addLazyObject(StringRef name, InputFile &file) { - Symbol *s; - bool wasInserted; - std::tie(s, wasInserted) = insert(name, &file); + auto [s, wasInserted] = insert(name, &file); if (wasInserted) { replaceSymbol(s, file, name);