diff options
| author | Eugene Zelenko <eugene.zelenko@gmail.com> | 2015-11-10 22:37:38 +0000 |
|---|---|---|
| committer | Eugene Zelenko <eugene.zelenko@gmail.com> | 2015-11-10 22:37:38 +0000 |
| commit | 4154794892292f6e3866e4f56ec74d9efcd2b007 (patch) | |
| tree | 53d69499d67df667a864b547b7f83e617a0aebac /lld/lib | |
| parent | 4f2a6cb2480affe5b475366ab24076b6a23993d7 (diff) | |
| download | bcm5719-llvm-4154794892292f6e3866e4f56ec74d9efcd2b007.tar.gz bcm5719-llvm-4154794892292f6e3866e4f56ec74d9efcd2b007.zip | |
Fix Clang-tidy modernize-use-auto warnings, other minor fixes.
Differential revision: http://reviews.llvm.org/D14553
llvm-svn: 252661
Diffstat (limited to 'lld/lib')
| -rw-r--r-- | lld/lib/Driver/Driver.cpp | 6 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp | 4 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/ELFFile.cpp | 12 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/ELFFile.h | 4 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/ELF/HeaderChunks.cpp | 6 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/LinkerScript.cpp | 19 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp | 6 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/File.h | 17 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/GOTPass.cpp | 9 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp | 22 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp | 30 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/StubsPass.cpp | 20 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/TLVPass.cpp | 7 |
13 files changed, 53 insertions, 109 deletions
diff --git a/lld/lib/Driver/Driver.cpp b/lld/lib/Driver/Driver.cpp index df7bde71081..a040e9cbdc5 100644 --- a/lld/lib/Driver/Driver.cpp +++ b/lld/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 @@ bool Driver::link(LinkingContext &ctx, raw_ostream &diagnostics) { // 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 @@ bool Driver::link(LinkingContext &ctx, raw_ostream &diagnostics) { return true; } -} // anonymous namespace +} // namespace lld diff --git a/lld/lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp b/lld/lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp index 7b52cf58cac..ff4b600158b 100644 --- a/lld/lib/ReaderWriter/ELF/AMDGPU/AMDGPUTargetHandler.cpp +++ b/lld/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 @@ void AMDGPUTargetLayout::assignSectionsToSegments() { if (InputSectionName != ".hsatext") continue; - Segment<ELF64LE> *segment = new (_allocator) Segment<ELF64LE>( + auto *segment = new (_allocator) Segment<ELF64LE>( _ctx, "PT_AMDGPU_HSA_LOAD_CODE_AGENT", PT_AMDGPU_HSA_LOAD_CODE_AGENT); _segments.push_back(segment); assert(segment); diff --git a/lld/lib/ReaderWriter/ELF/ELFFile.cpp b/lld/lib/ReaderWriter/ELF/ELFFile.cpp index 66f3a012f05..1488f1862b8 100644 --- a/lld/lib/ReaderWriter/ELF/ELFFile.cpp +++ b/lld/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::error_code ELFFile<ELFT>::handleGnuLinkOnceSection( std::vector<ELFReference<ELFT> *> refs; for (auto ha : atomsForSection[*sectionName]) { _groupChild[ha->symbol()] = std::make_pair(*sectionName, section); - ELFReference<ELFT> *ref = + auto *ref = new (_readerStorage) ELFReference<ELFT>(Reference::kindGroupChild); ref->setTarget(ha); refs.push_back(ref); @@ -536,7 +536,7 @@ std::error_code ELFFile<ELFT>::handleSectionGroup( for (auto name : sectionNames) { for (auto ha : atomsForSection[name]) { _groupChild[ha->symbol()] = std::make_pair(*symbolName, section); - ELFReference<ELFT> *ref = + auto *ref = new (_readerStorage) ELFReference<ELFT>(Reference::kindGroupChild); ref->setTarget(ha); refs.push_back(ref); @@ -727,7 +727,7 @@ template <class ELFT> ELFDefinedAtom<ELFT> * ELFFile<ELFT>::createSectionAtom(const Elf_Shdr *section, StringRef sectionName, ArrayRef<uint8_t> 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 @@ bool ELFFile<ELFT>::redirectReferenceUsingUndefAtom( template <class ELFT> void RuntimeFile<ELFT>::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 @@ void RuntimeFile<ELFT>::addAbsoluteAtom(StringRef symbolName, bool isHidden) { template <class ELFT> void RuntimeFile<ELFT>::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; diff --git a/lld/lib/ReaderWriter/ELF/ELFFile.h b/lld/lib/ReaderWriter/ELF/ELFFile.h index 8ed1f5e1a06..5e0c2fc75a8 100644 --- a/lld/lib/ReaderWriter/ELF/ELFFile.h +++ b/lld/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 @@ protected: const Elf_Shdr *sectionHdr, ArrayRef<uint8_t> contentData, unsigned int offset) { - ELFMergeAtom<ELFT> *mergeAtom = new (_readerStorage) + auto *mergeAtom = new (_readerStorage) ELFMergeAtom<ELFT>(*this, sectionName, sectionHdr, contentData, offset); const MergeSectionKey mergedSectionKey = {sectionHdr, offset}; if (_mergedSectionMap.find(mergedSectionKey) == _mergedSectionMap.end()) diff --git a/lld/lib/ReaderWriter/ELF/HeaderChunks.cpp b/lld/lib/ReaderWriter/ELF/HeaderChunks.cpp index 0bd4b3e03cf..193937c1806 100644 --- a/lld/lib/ReaderWriter/ELF/HeaderChunks.cpp +++ b/lld/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 @@ SectionHeader<ELFT>::SectionHeader(const ELFLinkingContext &ctx, int32_t order) this->_alignment = 8; this->setOrder(order); // The first element in the list is always NULL - Elf_Shdr *nullshdr = new (_sectionAllocate.Allocate<Elf_Shdr>()) Elf_Shdr; + auto *nullshdr = new (_sectionAllocate.Allocate<Elf_Shdr>()) Elf_Shdr; ::memset(nullshdr, 0, sizeof(Elf_Shdr)); _sectionInfo.push_back(nullshdr); this->_fsize += sizeof(Elf_Shdr); @@ -143,7 +143,7 @@ SectionHeader<ELFT>::SectionHeader(const ELFLinkingContext &ctx, int32_t order) template <class ELFT> void SectionHeader<ELFT>::appendSection(OutputSection<ELFT> *section) { - Elf_Shdr *shdr = new (_sectionAllocate.Allocate<Elf_Shdr>()) Elf_Shdr; + auto *shdr = new (_sectionAllocate.Allocate<Elf_Shdr>()) Elf_Shdr; shdr->sh_name = _stringSection->addString(section->name()); shdr->sh_type = section->type(); shdr->sh_flags = section->flags(); diff --git a/lld/lib/ReaderWriter/LinkerScript.cpp b/lld/lib/ReaderWriter/LinkerScript.cpp index f99a95150ed..67822dc48fe 100644 --- a/lld/lib/ReaderWriter/LinkerScript.cpp +++ b/lld/lib/ReaderWriter/LinkerScript.cpp @@ -1,4 +1,4 @@ -//===- ReaderWriter/LinkerScript.cpp --------------------------------------===// +//===- ReaderWriter/LinkerScript.cpp ----------------------------*- C++ -*-===// // // The LLVM Linker // @@ -1019,7 +1019,6 @@ void Extern::dump(raw_ostream &os) const { os << ")\n"; } - // Parser functions std::error_code Parser::parse() { // Get the first token. @@ -1183,7 +1182,7 @@ const Expression *Parser::parseExprOperand() { 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 @@ const Expression *Parser::parseExprOperand() { 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 @@ Memory *Parser::parseMemory() { 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 @@ int Sema::getLayoutOrder(const SectionKey &key, bool coarse) const { // 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 @@ void Sema::linearizeAST(const Sections *sections) { } } -} // End namespace script +} // end namespace script } // end namespace lld diff --git a/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp b/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp index 65bd52c7ce8..4b8644a67e7 100644 --- a/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp +++ b/lld/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 @@ private: << " 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 @@ private: }); } - CompactUnwindEntry finalizeUnwindInfoEntryForAtom( const DefinedAtom *function, const std::map<const Atom *, CompactUnwindEntry> &unwindLocs, @@ -549,7 +548,6 @@ private: } } - auto personality = std::find(personalities.begin(), personalities.end(), entry.personalityFunction); uint32_t personalityIdx = personality == personalities.end() diff --git a/lld/lib/ReaderWriter/MachO/File.h b/lld/lib/ReaderWriter/MachO/File.h index 364b8c2bd52..e9f2eed23a4 100644 --- a/lld/lib/ReaderWriter/MachO/File.h +++ b/lld/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 @@ public: 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 @@ public: 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 @@ public: 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 @@ public: // 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 @@ public: // 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 @@ private: addAtom(*atom); } - typedef llvm::DenseMap<const normalized::Section *, std::vector<SectionOffsetAndAtom>> SectionToAtoms; typedef llvm::StringMap<const lld::Atom *> NameToAtom; @@ -298,7 +296,6 @@ private: return nullptr; } - struct ReExportedDylib { ReExportedDylib(StringRef p) : path(p), file(nullptr) { } StringRef path; @@ -324,4 +321,4 @@ private: } // end namespace mach_o } // end namespace lld -#endif +#endif // LLD_READER_WRITER_MACHO_FILE_H diff --git a/lld/lib/ReaderWriter/MachO/GOTPass.cpp b/lld/lib/ReaderWriter/MachO/GOTPass.cpp index ab8c4403231..a5816277dd7 100644 --- a/lld/lib/ReaderWriter/MachO/GOTPass.cpp +++ b/lld/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 @@ private: StringRef _name; }; - /// Pass for instantiating and optimizing GOT slots. /// class GOTPass : public Pass { @@ -155,7 +153,7 @@ private: 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 @@ private: llvm::DenseMap<const Atom*, const GOTEntryAtom*> _targetToGOT; }; - - void addGOTPass(PassManager &pm, const MachOLinkingContext &ctx) { assert(ctx.needsGOTPass()); pm.add(llvm::make_unique<GOTPass>(ctx)); } - } // end namesapce mach_o } // end namesapce lld diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp index d1577556e1e..7afb2539579 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp @@ -149,6 +149,7 @@ private: const uint8_t *bytes() { return reinterpret_cast<const uint8_t*>(_ostream.str().data()); } + private: SmallVector<char, 128> _bytes; // Stream ivar must be after SmallVector ivar to construct properly. @@ -168,14 +169,14 @@ private: 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<TrieNode *> &allNodes); bool updateOffset(uint32_t &offset); void appendToByteBuffer(ByteBuffer &out); -private: + private: StringRef _cummulativeString; std::list<TrieEdge> _children; uint64_t _address; @@ -262,7 +263,6 @@ size_t MachOFileLayout::headerAndLoadCommandsSize() const { return _endOfLoadCommands; } - MachOFileLayout::MachOFileLayout(const NormalizedFile &file) : _file(file), _is64(MachOLinkingContext::is64Bit(file.arch)), @@ -548,7 +548,6 @@ void MachOFileLayout::buildFileOffsets() { _startOfLinkEdit = fileOffset; } - size_t MachOFileLayout::size() const { return _endOfSymbolStrings; } @@ -881,7 +880,6 @@ std::error_code MachOFileLayout::writeLoadCommands() { return ec; } - void MachOFileLayout::writeSectionContent() { for (const Section &s : _file.sections) { // Copy all section content to output buffer. @@ -908,7 +906,6 @@ void MachOFileLayout::writeRelocations() { } } - void MachOFileLayout::appendSymbols(const std::vector<Symbol> &symbols, uint32_t &symOffset, uint32_t &strOffset) { for (const Symbol &sym : symbols) { @@ -1099,7 +1096,7 @@ void MachOFileLayout::TrieNode::addSymbol(const Export& entry, // 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 @@ void MachOFileLayout::TrieNode::addSymbol(const Export& entry, 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 @@ void MachOFileLayout::TrieNode::addSymbol(const Export& entry, 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 @@ void MachOFileLayout::buildExportTrie() { BumpPtrAllocator allocator; // Build trie of all exported symbols. - TrieNode* rootNode = new (allocator) TrieNode(StringRef()); + auto *rootNode = new (allocator) TrieNode(StringRef()); std::vector<TrieNode*> allNodes; allNodes.reserve(_file.exportInfo.size()*2); allNodes.push_back(rootNode); @@ -1266,7 +1263,6 @@ void MachOFileLayout::buildExportTrie() { _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 @@ std::error_code MachOFileLayout::writeBinary(StringRef path) { 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 diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp index 9585691a8d3..d6e0c922686 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp @@ -90,7 +90,6 @@ SegmentInfo::SegmentInfo(StringRef n) : name(n), address(0), size(0), access(0), normalizedSegmentIndex(0) { } - class Util { public: Util(const MachOLinkingContext &ctxt) @@ -207,7 +206,7 @@ SectionInfo *Util::getRelocatableSection(DefinedAtom::ContentType type) { } } // 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 @@ const MachOFinalSectionFromAtomType sectsToAtomType[] = { }; #undef ENTRY - SectionInfo *Util::getFinalSection(DefinedAtom::ContentType atomType) { for (auto &p : sectsToAtomType) { if (p.atomType != atomType) @@ -286,7 +284,7 @@ SectionInfo *Util::getFinalSection(DefinedAtom::ContentType atomType) { } } // 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 @@ SectionInfo *Util::getFinalSection(DefinedAtom::ContentType atomType) { 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 @@ SectionInfo *Util::sectionForAtom(const DefinedAtom *atom) { 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 @@ SectionInfo *Util::sectionForAtom(const DefinedAtom *atom) { } } - 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 @@ SegmentInfo *Util::segmentForName(StringRef segName) { 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 @@ bool Util::TextSectionSorter::operator()(const SectionInfo *left, 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::organizeSections() { } } } - } - void Util::layoutSectionsInSegment(SegmentInfo *seg, uint64_t &addr) { seg->address = addr; for (SectionInfo *sect : seg->sections) { @@ -469,7 +461,6 @@ void Util::layoutSectionsInSegment(SegmentInfo *seg, uint64_t &addr) { 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 @@ void Util::layoutSectionsInTextSegment(size_t hlcSize, SegmentInfo *seg, 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::assignAddressesToSections(const NormalizedFile &file) { } } - void Util::copySegmentInfo(NormalizedFile &file) { for (SegmentInfo *sgi : _segmentInfos) { Segment seg; @@ -611,7 +600,6 @@ void Util::copySectionContent(NormalizedFile &file) { } } - void Util::copySectionInfo(NormalizedFile &file) { file.sections.reserve(_sectionInfos.size()); // For final linked images, write sections grouped by segment. @@ -717,13 +705,11 @@ uint16_t Util::descBits(const DefinedAtom* atom) { 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 @@ std::error_code Util::addSymbols(const lld::File &atomFile, file.globalSymbols.push_back(sym); } - // Sort undefined symbol alphabetically, then add to symbol table. std::vector<AtomAndIndex> undefs; undefs.reserve(128); @@ -895,7 +880,6 @@ const Atom *Util::targetOfStub(const DefinedAtom *stubAtom) { 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 @@ void Util::addIndirectSymbols(const lld::File &atomFile, NormalizedFile &file) { break; } } - } void Util::addDependentDylibs(const lld::File &atomFile,NormalizedFile &nFile) { @@ -994,7 +977,6 @@ void Util::addDependentDylibs(const lld::File &atomFile,NormalizedFile &nFile) { } } - int Util::dylibOrdinal(const SharedLibraryAtom *sa) { return _dylibInfo[sa->loadName()].ordinal; } @@ -1013,7 +995,6 @@ void Util::segIndexForSection(const SectionInfo *sect, uint8_t &segmentIndex, 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 @@ void Util::addSectionRelocs(const lld::File &, NormalizedFile &file) { 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 @@ uint32_t Util::fileFlags() { } // end anonymous namespace - namespace lld { namespace mach_o { namespace normalized { @@ -1252,7 +1231,6 @@ normalizedFromAtoms(const lld::File &atomFile, return std::move(f); } - } // namespace normalized } // namespace mach_o } // namespace lld diff --git a/lld/lib/ReaderWriter/MachO/StubsPass.cpp b/lld/lib/ReaderWriter/MachO/StubsPass.cpp index 8eee9e6febe..1f61256a5b7 100644 --- a/lld/lib/ReaderWriter/MachO/StubsPass.cpp +++ b/lld/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 @@ private: const bool _is64; }; - // // NonLazyPointer (GOT) Atom created by the stubs pass. // @@ -100,8 +97,6 @@ private: const bool _is64; }; - - // // Stub Atom created by the stubs pass. // @@ -134,7 +129,6 @@ private: const ArchHandler::StubInfo &_stubInfo; }; - // // Stub Helper Atom created by the stubs pass. // @@ -168,7 +162,6 @@ private: const ArchHandler::StubInfo &_stubInfo; }; - // // Stub Helper Common Atom created by the stubs pass. // @@ -202,7 +195,6 @@ private: const ArchHandler::StubInfo &_stubInfo; }; - class StubsPass : public Pass { public: StubsPass(const MachOLinkingContext &context) @@ -284,11 +276,10 @@ public: // 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 = - new (_file.allocator()) StubHelperAtom(_file, _stubInfo); + auto *helper = new (_file.allocator()) StubHelperAtom(_file, _stubInfo); addReference(stub, _stubInfo.stubReferenceToLP, lp); addOptReference(stub, _stubInfo.stubReferenceToLP, @@ -320,7 +311,6 @@ public: } private: - bool noTextRelocs() { return true; } @@ -365,8 +355,6 @@ private: TargetToUses _targetToUses; }; - - void addStubsPass(PassManager &pm, const MachOLinkingContext &ctx) { pm.add(std::unique_ptr<Pass>(new StubsPass(ctx))); } diff --git a/lld/lib/ReaderWriter/MachO/TLVPass.cpp b/lld/lib/ReaderWriter/MachO/TLVPass.cpp index fa6ccae7599..aba222edcd2 100644 --- a/lld/lib/ReaderWriter/MachO/TLVPass.cpp +++ b/lld/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 @@ public: _file("<mach-o TLV Pass>") {} 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 @@ private: 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 @@ void addTLVPass(PassManager &pm, const MachOLinkingContext &ctx) { pm.add(llvm::make_unique<TLVPass>(ctx)); } - } // end namesapce mach_o } // end namesapce lld |

