Index: lib/Driver/Driver.cpp =================================================================== --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -1,4 +1,4 @@ -//===- lib/Driver/Driver.cpp - Linker Driver Emulator ---------------------===// +//===- lib/Driver/Driver.cpp - Linker Driver Emulator -----------*- C++ -*-===// // // The LLVM Linker // @@ -69,7 +69,7 @@ // Honor -mllvm if (!ctx.llvmOptions().empty()) { unsigned numArgs = ctx.llvmOptions().size(); - const char **args = new const char *[numArgs + 2]; + auto **args = new const char *[numArgs + 2]; args[0] = "lld (LLVM option parsing)"; for (unsigned i = 0; i != numArgs; ++i) args[i + 1] = ctx.llvmOptions()[i]; @@ -136,4 +136,4 @@ return true; } -} // anonymous namespace +} // namespace lld Index: lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp =================================================================== --- lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp +++ lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp @@ -1,4 +1,4 @@ -//===- lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp ----------------===// +//===- lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp -------*- C++ -*-===// // // The LLVM Linker // @@ -52,7 +52,7 @@ if (InputSectionName != ".hsatext") continue; - Segment *segment = new (_allocator) Segment( + auto *segment = new (_allocator) Segment( _ctx, "PT_AMDGPU_HSA_LOAD_CODE_AGENT", PT_AMDGPU_HSA_LOAD_CODE_AGENT); _segments.push_back(segment); assert(segment); Index: lib/ReaderWriter/ELF/ELFFile.h =================================================================== --- lib/ReaderWriter/ELF/ELFFile.h +++ lib/ReaderWriter/ELF/ELFFile.h @@ -1,4 +1,4 @@ -//===- lib/ReaderWriter/ELF/ELFFile.h -------------------------------------===// +//===- lib/ReaderWriter/ELF/ELFFile.h ---------------------------*- C++ -*-===// // // The LLVM Linker // @@ -291,7 +291,7 @@ const Elf_Shdr *sectionHdr, ArrayRef contentData, unsigned int offset) { - ELFMergeAtom *mergeAtom = new (_readerStorage) + auto *mergeAtom = new (_readerStorage) ELFMergeAtom(*this, sectionName, sectionHdr, contentData, offset); const MergeSectionKey mergedSectionKey = {sectionHdr, offset}; if (_mergedSectionMap.find(mergedSectionKey) == _mergedSectionMap.end()) Index: lib/ReaderWriter/ELF/ELFFile.cpp =================================================================== --- lib/ReaderWriter/ELF/ELFFile.cpp +++ lib/ReaderWriter/ELF/ELFFile.cpp @@ -1,4 +1,4 @@ -//===- lib/ReaderWriter/ELF/ELFFile.cpp -----------------------------------===// +//===- lib/ReaderWriter/ELF/ELFFile.cpp -------------------------*- C++ -*-===// // // The LLVM Linker // @@ -462,7 +462,7 @@ std::vector *> refs; for (auto ha : atomsForSection[*sectionName]) { _groupChild[ha->symbol()] = std::make_pair(*sectionName, section); - ELFReference *ref = + auto *ref = new (_readerStorage) ELFReference(Reference::kindGroupChild); ref->setTarget(ha); refs.push_back(ref); @@ -536,7 +536,7 @@ for (auto name : sectionNames) { for (auto ha : atomsForSection[name]) { _groupChild[ha->symbol()] = std::make_pair(*symbolName, section); - ELFReference *ref = + auto *ref = new (_readerStorage) ELFReference(Reference::kindGroupChild); ref->setTarget(ha); refs.push_back(ref); @@ -727,7 +727,7 @@ ELFDefinedAtom * ELFFile::createSectionAtom(const Elf_Shdr *section, StringRef sectionName, ArrayRef content) { - Elf_Sym *sym = new (_readerStorage) Elf_Sym; + auto *sym = new (_readerStorage) Elf_Sym; sym->st_name = 0; sym->setBindingAndType(llvm::ELF::STB_LOCAL, llvm::ELF::STT_SECTION); sym->st_other = 0; @@ -787,7 +787,7 @@ template void RuntimeFile::addAbsoluteAtom(StringRef symbolName, bool isHidden) { assert(!symbolName.empty() && "AbsoluteAtoms must have a name"); - Elf_Sym *sym = new (this->_readerStorage) Elf_Sym; + auto *sym = new (this->_readerStorage) Elf_Sym; sym->st_name = 0; sym->st_value = 0; sym->st_shndx = llvm::ELF::SHN_ABS; @@ -804,7 +804,7 @@ template void RuntimeFile::addUndefinedAtom(StringRef symbolName) { assert(!symbolName.empty() && "UndefinedAtoms must have a name"); - Elf_Sym *sym = new (this->_readerStorage) Elf_Sym; + auto *sym = new (this->_readerStorage) Elf_Sym; sym->st_name = 0; sym->st_value = 0; sym->st_shndx = llvm::ELF::SHN_UNDEF; Index: lib/ReaderWriter/ELF/HeaderChunks.cpp =================================================================== --- lib/ReaderWriter/ELF/HeaderChunks.cpp +++ lib/ReaderWriter/ELF/HeaderChunks.cpp @@ -1,4 +1,4 @@ -//===- lib/ReaderWriter/ELF/HeaderChunks.cpp ------------------------------===// +//===- lib/ReaderWriter/ELF/HeaderChunks.cpp --------------------*- C++ -*-===// // // The LLVM Linker // @@ -135,7 +135,7 @@ this->_alignment = 8; this->setOrder(order); // The first element in the list is always NULL - Elf_Shdr *nullshdr = new (_sectionAllocate.Allocate()) Elf_Shdr; + auto *nullshdr = new (_sectionAllocate.Allocate()) Elf_Shdr; ::memset(nullshdr, 0, sizeof(Elf_Shdr)); _sectionInfo.push_back(nullshdr); this->_fsize += sizeof(Elf_Shdr); @@ -143,7 +143,7 @@ template void SectionHeader::appendSection(OutputSection *section) { - Elf_Shdr *shdr = new (_sectionAllocate.Allocate()) Elf_Shdr; + auto *shdr = new (_sectionAllocate.Allocate()) Elf_Shdr; shdr->sh_name = _stringSection->addString(section->name()); shdr->sh_type = section->type(); shdr->sh_flags = section->flags(); Index: lib/ReaderWriter/LinkerScript.cpp =================================================================== --- lib/ReaderWriter/LinkerScript.cpp +++ lib/ReaderWriter/LinkerScript.cpp @@ -1,4 +1,4 @@ -//===- ReaderWriter/LinkerScript.cpp --------------------------------------===// +//===- ReaderWriter/LinkerScript.cpp ----------------------------*- C++ -*-===// // // The LLVM Linker // @@ -1019,7 +1019,6 @@ os << ")\n"; } - // Parser functions std::error_code Parser::parse() { // Get the first token. @@ -1183,7 +1182,7 @@ case Token::identifier: { if (peek()._kind== Token::l_paren) return parseFunctionCall(); - Symbol *sym = new (_alloc) Symbol(*this, _tok._range); + auto *sym = new (_alloc) Symbol(*this, _tok._range); consumeToken(); return sym; } @@ -1201,7 +1200,7 @@ error(_tok, "Unrecognized number constant"); return nullptr; } - Constant *c = new (_alloc) Constant(*this, *val); + auto *c = new (_alloc) Constant(*this, *val); consumeToken(); return c; } @@ -2354,8 +2353,7 @@ if (!length) return nullptr; - MemoryBlock *block = - new (_alloc) MemoryBlock(name, attrs, origin, length); + auto *block = new (_alloc) MemoryBlock(name, attrs, origin, length); blocks.push_back(block); } else { unrecognizedToken = true; @@ -2649,11 +2647,10 @@ // If we still couldn't find a rule for this input section, try to match // wildcards - for (auto I = _memberNameWildcards.begin(), E = _memberNameWildcards.end(); - I != E; ++I) { - if (!wildcardMatch(I->first, key.memberPath)) + for (const auto &I : _memberNameWildcards) { + if (!wildcardMatch(I.first, key.memberPath)) continue; - int order = I->second; + int order = I.second; int exprOrder = -1; if ((exprOrder = matchSectionName(order, key)) >= 0) { @@ -2894,5 +2891,5 @@ } } -} // End namespace script +} // end namespace script } // end namespace lld Index: lib/ReaderWriter/MachO/CompactUnwindPass.cpp =================================================================== --- lib/ReaderWriter/MachO/CompactUnwindPass.cpp +++ lib/ReaderWriter/MachO/CompactUnwindPass.cpp @@ -1,4 +1,4 @@ -//===- lib/ReaderWriter/MachO/CompactUnwindPass.cpp -----------------------===// +//===- lib/ReaderWriter/MachO/CompactUnwindPass.cpp -------------*- C++ -*-===// // // The LLVM Linker // @@ -342,7 +342,7 @@ << " has " << entriesInPage << " entries\n"); } while (pageStart < unwindInfos.size()); - UnwindInfoAtom *unwind = new (_file.allocator()) + auto *unwind = new (_file.allocator()) UnwindInfoAtom(_archHandler, _file, _isBig, personalities, commonEncodings, pages, numLSDAs); mergedFile.addAtom(*unwind); @@ -520,7 +520,6 @@ }); } - CompactUnwindEntry finalizeUnwindInfoEntryForAtom( const DefinedAtom *function, const std::map &unwindLocs, @@ -549,7 +548,6 @@ } } - auto personality = std::find(personalities.begin(), personalities.end(), entry.personalityFunction); uint32_t personalityIdx = personality == personalities.end() Index: lib/ReaderWriter/MachO/File.h =================================================================== --- lib/ReaderWriter/MachO/File.h +++ lib/ReaderWriter/MachO/File.h @@ -1,4 +1,4 @@ -//===- lib/ReaderWriter/MachO/File.h --------------------------------------===// +//===- lib/ReaderWriter/MachO/File.h ----------------------------*- C++ -*-===// // // The LLVM Linker // @@ -45,7 +45,7 @@ DefinedAtom::Alignment align( inSection->alignment, sectionOffset % inSection->alignment); - MachODefinedAtom *atom = + auto *atom = new (allocator()) MachODefinedAtom(*this, name, scope, type, merge, thumb, noDeadStrip, content, align); addAtomForSection(inSection, atom, sectionOffset); @@ -68,7 +68,7 @@ DefinedAtom::Alignment align( inSection->alignment, sectionOffset % inSection->alignment); - MachODefinedCustomSectionAtom *atom = + auto *atom = new (allocator()) MachODefinedCustomSectionAtom(*this, name, scope, type, merge, thumb, noDeadStrip, content, @@ -87,7 +87,7 @@ DefinedAtom::Alignment align( inSection->alignment, sectionOffset % inSection->alignment); - MachODefinedAtom *atom = + auto *atom = new (allocator()) MachODefinedAtom(*this, name, scope, size, noDeadStrip, align); addAtomForSection(inSection, atom, sectionOffset); @@ -98,8 +98,7 @@ // Make a copy of the atom's name that is owned by this file. name = name.copy(allocator()); } - SimpleUndefinedAtom *atom = - new (allocator()) SimpleUndefinedAtom(*this, name); + auto *atom = new (allocator()) SimpleUndefinedAtom(*this, name); addAtom(*atom); _undefAtoms[name] = atom; } @@ -110,7 +109,7 @@ // Make a copy of the atom's name that is owned by this file. name = name.copy(allocator()); } - MachOTentativeDefAtom *atom = + auto *atom = new (allocator()) MachOTentativeDefAtom(*this, name, scope, size, align); addAtom(*atom); _undefAtoms[name] = atom; @@ -200,7 +199,6 @@ addAtom(*atom); } - typedef llvm::DenseMap> SectionToAtoms; typedef llvm::StringMap NameToAtom; @@ -298,7 +296,6 @@ return nullptr; } - struct ReExportedDylib { ReExportedDylib(StringRef p) : path(p), file(nullptr) { } StringRef path; @@ -324,4 +321,4 @@ } // end namespace mach_o } // end namespace lld -#endif +#endif // LLD_READER_WRITER_MACHO_FILE_H Index: lib/ReaderWriter/MachO/GOTPass.cpp =================================================================== --- lib/ReaderWriter/MachO/GOTPass.cpp +++ lib/ReaderWriter/MachO/GOTPass.cpp @@ -1,4 +1,4 @@ -//===- lib/ReaderWriter/MachO/GOTPass.cpp ---------------------------------===// +//===- lib/ReaderWriter/MachO/GOTPass.cpp -----------------------*- C++ -*-===// // // The LLVM Linker // @@ -46,7 +46,6 @@ namespace lld { namespace mach_o { - // // GOT Entry Atom created by the GOT pass. // @@ -86,7 +85,6 @@ StringRef _name; }; - /// Pass for instantiating and optimizing GOT slots. /// class GOTPass : public Pass { @@ -155,7 +153,7 @@ const DefinedAtom *makeGOTEntry(const Atom *target) { auto pos = _targetToGOT.find(target); if (pos == _targetToGOT.end()) { - GOTEntryAtom *gotEntry = new (_file.allocator()) + auto *gotEntry = new (_file.allocator()) GOTEntryAtom(_file, _ctx.is64Bit(), target->name()); _targetToGOT[target] = gotEntry; const ArchHandler::ReferenceInfo &nlInfo = _archHandler.stubInfo(). @@ -173,13 +171,10 @@ llvm::DenseMap _targetToGOT; }; - - void addGOTPass(PassManager &pm, const MachOLinkingContext &ctx) { assert(ctx.needsGOTPass()); pm.add(llvm::make_unique(ctx)); } - } // end namesapce mach_o } // end namesapce lld Index: lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp =================================================================== --- lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp +++ lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp @@ -149,6 +149,7 @@ const uint8_t *bytes() { return reinterpret_cast(_ostream.str().data()); } + private: SmallVector _bytes; // Stream ivar must be after SmallVector ivar to construct properly. @@ -168,14 +169,14 @@ TrieNode(StringRef s) : _cummulativeString(s), _address(0), _flags(0), _other(0), _trieOffset(0), _hasExportInfo(false) {} - ~TrieNode() {} + ~TrieNode() = default; void addSymbol(const Export &entry, BumpPtrAllocator &allocator, std::vector &allNodes); bool updateOffset(uint32_t &offset); void appendToByteBuffer(ByteBuffer &out); -private: + private: StringRef _cummulativeString; std::list _children; uint64_t _address; @@ -262,7 +263,6 @@ return _endOfLoadCommands; } - MachOFileLayout::MachOFileLayout(const NormalizedFile &file) : _file(file), _is64(MachOLinkingContext::is64Bit(file.arch)), @@ -548,7 +548,6 @@ _startOfLinkEdit = fileOffset; } - size_t MachOFileLayout::size() const { return _endOfSymbolStrings; } @@ -881,7 +880,6 @@ return ec; } - void MachOFileLayout::writeSectionContent() { for (const Section &s : _file.sections) { // Copy all section content to output buffer. @@ -908,7 +906,6 @@ } } - void MachOFileLayout::appendSymbols(const std::vector &symbols, uint32_t &symOffset, uint32_t &strOffset) { for (const Symbol &sym : symbols) { @@ -1099,7 +1096,7 @@ // Splice in new node: was A -> C, now A -> B -> C StringRef bNodeStr = edge._child->_cummulativeString; bNodeStr = bNodeStr.drop_back(edgeStr.size()-n).copy(allocator); - TrieNode* bNode = new (allocator) TrieNode(bNodeStr); + auto *bNode = new (allocator) TrieNode(bNodeStr); allNodes.push_back(bNode); TrieNode* cNode = edge._child; StringRef abEdgeStr = edgeStr.substr(0,n).copy(allocator); @@ -1112,7 +1109,7 @@ TrieEdge& abEdge = edge; abEdge._subString = abEdgeStr; abEdge._child = bNode; - TrieEdge *bcEdge = new (allocator) TrieEdge(bcEdgeStr, cNode); + auto *bcEdge = new (allocator) TrieEdge(bcEdgeStr, cNode); bNode->_children.push_back(std::move(*bcEdge)); bNode->addSymbol(entry, allocator, allNodes); return; @@ -1126,8 +1123,8 @@ assert(entry.otherOffset != 0); } // No commonality with any existing child, make a new edge. - TrieNode* newNode = new (allocator) TrieNode(entry.name.copy(allocator)); - TrieEdge *newEdge = new (allocator) TrieEdge(partialStr, newNode); + auto *newNode = new (allocator) TrieNode(entry.name.copy(allocator)); + auto *newEdge = new (allocator) TrieEdge(partialStr, newNode); _children.push_back(std::move(*newEdge)); DEBUG_WITH_TYPE("trie-builder", llvm::dbgs() << "new TrieNode('" << entry.name << "') with edge '" @@ -1239,7 +1236,7 @@ BumpPtrAllocator allocator; // Build trie of all exported symbols. - TrieNode* rootNode = new (allocator) TrieNode(StringRef()); + auto *rootNode = new (allocator) TrieNode(StringRef()); std::vector allNodes; allNodes.reserve(_file.exportInfo.size()*2); allNodes.push_back(rootNode); @@ -1266,7 +1263,6 @@ _exportTrie.align(_is64 ? 8 : 4); } - void MachOFileLayout::computeSymbolTableSizes() { // MachO symbol tables have three ranges: locals, globals, and undefines const size_t nlistSize = (_is64 ? sizeof(nlist_64) : sizeof(nlist)); @@ -1340,14 +1336,12 @@ return std::error_code(); } - /// Takes in-memory normalized view and writes a mach-o object file. std::error_code writeBinary(const NormalizedFile &file, StringRef path) { MachOFileLayout layout(file); return layout.writeBinary(path); } - } // namespace normalized } // namespace mach_o } // namespace lld Index: lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp =================================================================== --- lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp +++ lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp @@ -90,7 +90,6 @@ : name(n), address(0), size(0), access(0), normalizedSegmentIndex(0) { } - class Util { public: Util(const MachOLinkingContext &ctxt) @@ -207,7 +206,7 @@ } } // Otherwise allocate new SectionInfo object. - SectionInfo *sect = new (_allocator) + auto *sect = new (_allocator) SectionInfo(segmentName, sectionName, sectionType, _ctx, sectionAttrs); _sectionInfos.push_back(sect); _sectionMap[type] = sect; @@ -259,7 +258,6 @@ }; #undef ENTRY - SectionInfo *Util::getFinalSection(DefinedAtom::ContentType atomType) { for (auto &p : sectsToAtomType) { if (p.atomType != atomType) @@ -286,7 +284,7 @@ } } // Otherwise allocate new SectionInfo object. - SectionInfo *sect = new (_allocator) SectionInfo( + auto *sect = new (_allocator) SectionInfo( p.segmentName, p.sectionName, p.sectionType, _ctx, sectionAttrs); _sectionInfos.push_back(sect); _sectionMap[atomType] = sect; @@ -295,8 +293,6 @@ llvm_unreachable("content type not yet supported"); } - - SectionInfo *Util::sectionForAtom(const DefinedAtom *atom) { if (atom->sectionChoice() == DefinedAtom::sectionBasedOnContent) { // Section for this atom is derived from content type. @@ -321,7 +317,7 @@ assert(seperatorIndex != StringRef::npos); StringRef segName = customName.slice(0, seperatorIndex); StringRef sectName = customName.drop_front(seperatorIndex + 1); - SectionInfo *sect = + auto *sect = new (_allocator) SectionInfo(segName, sectName, S_REGULAR, _ctx); _customSections.push_back(sect); _sectionInfos.push_back(sect); @@ -329,7 +325,6 @@ } } - void Util::appendAtom(SectionInfo *sect, const DefinedAtom *atom) { // Figure out offset for atom in this section given alignment constraints. uint64_t offset = sect->size; @@ -367,7 +362,7 @@ if ( si->name.equals(segName) ) return si; } - SegmentInfo *info = new (_allocator) SegmentInfo(segName); + auto *info = new (_allocator) SegmentInfo(segName); if (segName.equals("__TEXT")) info->access = VM_PROT_READ | VM_PROT_EXECUTE; else if (segName.equals("__DATA")) @@ -408,7 +403,6 @@ return (weight(left) < weight(right)); } - void Util::organizeSections() { if (_ctx.outputMachOType() == llvm::MachO::MH_OBJECT) { // Leave sections ordered as normalized file specified. @@ -456,10 +450,8 @@ } } } - } - void Util::layoutSectionsInSegment(SegmentInfo *seg, uint64_t &addr) { seg->address = addr; for (SectionInfo *sect : seg->sections) { @@ -469,7 +461,6 @@ seg->size = llvm::RoundUpToAlignment(addr - seg->address, _ctx.pageSize()); } - // __TEXT segment lays out backwards so padding is at front after load commands. void Util::layoutSectionsInTextSegment(size_t hlcSize, SegmentInfo *seg, uint64_t &addr) { @@ -493,7 +484,6 @@ seg->size = llvm::RoundUpToAlignment(addr - seg->address, _ctx.pageSize()); } - void Util::assignAddressesToSections(const NormalizedFile &file) { size_t hlcSize = headerAndLoadCommandsSize(file); uint64_t address = 0; @@ -545,7 +535,6 @@ } } - void Util::copySegmentInfo(NormalizedFile &file) { for (SegmentInfo *sgi : _segmentInfos) { Segment seg; @@ -611,7 +600,6 @@ } } - void Util::copySectionInfo(NormalizedFile &file) { file.sections.reserve(_sectionInfos.size()); // For final linked images, write sections grouped by segment. @@ -717,13 +705,11 @@ return desc; } - bool Util::AtomSorter::operator()(const AtomAndIndex &left, const AtomAndIndex &right) { return (left.atom->name().compare(right.atom->name()) < 0); } - std::error_code Util::getSymbolTableRegion(const DefinedAtom* atom, bool &inGlobalsRegion, SymbolScope &scope) { @@ -837,7 +823,6 @@ file.globalSymbols.push_back(sym); } - // Sort undefined symbol alphabetically, then add to symbol table. std::vector undefs; undefs.reserve(128); @@ -895,7 +880,6 @@ return nullptr; } - void Util::addIndirectSymbols(const lld::File &atomFile, NormalizedFile &file) { for (SectionInfo *si : _sectionInfos) { Section &normSect = file.sections[si->normalizedSectionIndex]; @@ -944,7 +928,6 @@ break; } } - } void Util::addDependentDylibs(const lld::File &atomFile,NormalizedFile &nFile) { @@ -994,7 +977,6 @@ } } - int Util::dylibOrdinal(const SharedLibraryAtom *sa) { return _dylibInfo[sa->loadName()].ordinal; } @@ -1013,7 +995,6 @@ llvm_unreachable("section not in any segment"); } - uint32_t Util::sectionIndexForAtom(const Atom *atom) { uint64_t address = _atomToAddress[atom]; uint32_t index = 1; @@ -1029,7 +1010,6 @@ if (_ctx.outputMachOType() != llvm::MachO::MH_OBJECT) return; - // Utility function for ArchHandler to find symbol index for an atom. auto symIndexForAtom = [&] (const Atom &atom) -> uint32_t { auto pos = _atomToSymbolIndex.find(&atom); @@ -1207,7 +1187,6 @@ } // end anonymous namespace - namespace lld { namespace mach_o { namespace normalized { @@ -1252,7 +1231,6 @@ return std::move(f); } - } // namespace normalized } // namespace mach_o } // namespace lld Index: lib/ReaderWriter/MachO/StubsPass.cpp =================================================================== --- lib/ReaderWriter/MachO/StubsPass.cpp +++ lib/ReaderWriter/MachO/StubsPass.cpp @@ -1,4 +1,4 @@ -//===- lib/ReaderWriter/MachO/StubsPass.cpp -------------------------------===// +//===- lib/ReaderWriter/MachO/StubsPass.cpp ---------------------*- C++ -*-===// // // The LLVM Linker // @@ -26,11 +26,9 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" - namespace lld { namespace mach_o { - // // Lazy Pointer Atom created by the stubs pass. // @@ -65,7 +63,6 @@ const bool _is64; }; - // // NonLazyPointer (GOT) Atom created by the stubs pass. // @@ -100,8 +97,6 @@ const bool _is64; }; - - // // Stub Atom created by the stubs pass. // @@ -134,7 +129,6 @@ const ArchHandler::StubInfo &_stubInfo; }; - // // Stub Helper Atom created by the stubs pass. // @@ -168,7 +162,6 @@ const ArchHandler::StubInfo &_stubInfo; }; - // // Stub Helper Common Atom created by the stubs pass. // @@ -202,7 +195,6 @@ const ArchHandler::StubInfo &_stubInfo; }; - class StubsPass : public Pass { public: StubsPass(const MachOLinkingContext &context) @@ -284,10 +276,10 @@ // Make and append stubs, lazy pointers, and helpers in alphabetical order. unsigned lazyOffset = 0; for (const Atom *target : targetsNeedingStubs) { - StubAtom *stub = new (_file.allocator()) StubAtom(_file, _stubInfo); - LazyPointerAtom *lp = + auto *stub = new (_file.allocator()) StubAtom(_file, _stubInfo); + auto *lp = new (_file.allocator()) LazyPointerAtom(_file, _ctx.is64Bit()); - StubHelperAtom *helper = + auto *helper = new (_file.allocator()) StubHelperAtom(_file, _stubInfo); addReference(stub, _stubInfo.stubReferenceToLP, lp); @@ -320,7 +312,6 @@ } private: - bool noTextRelocs() { return true; } @@ -365,8 +356,6 @@ TargetToUses _targetToUses; }; - - void addStubsPass(PassManager &pm, const MachOLinkingContext &ctx) { pm.add(std::unique_ptr(new StubsPass(ctx))); } Index: lib/ReaderWriter/MachO/TLVPass.cpp =================================================================== --- lib/ReaderWriter/MachO/TLVPass.cpp +++ lib/ReaderWriter/MachO/TLVPass.cpp @@ -1,4 +1,4 @@ -//===- lib/ReaderWriter/MachO/TLVPass.cpp ---------------------------------===// +//===- lib/ReaderWriter/MachO/TLVPass.cpp -----------------------*- C++ -*-===// // // The LLVM Linker // @@ -68,9 +68,7 @@ _file("") {} private: - std::error_code perform(SimpleFile &mergedFile) override { - bool allowTLV = _ctx.minOS("10.7", "1.0"); for (const DefinedAtom *atom : mergedFile.defined()) { @@ -114,7 +112,7 @@ if (pos != _targetToTLVP.end()) return pos->second; - TLVPEntryAtom *tlvpEntry = new (_file.allocator()) + auto *tlvpEntry = new (_file.allocator()) TLVPEntryAtom(_file, _ctx.is64Bit(), target->name()); _targetToTLVP[target] = tlvpEntry; const ArchHandler::ReferenceInfo &nlInfo = @@ -135,6 +133,5 @@ pm.add(llvm::make_unique(ctx)); } - } // end namesapce mach_o } // end namesapce lld