diff options
| author | Rui Ueyama <ruiu@google.com> | 2015-04-10 21:40:59 +0000 |
|---|---|---|
| committer | Rui Ueyama <ruiu@google.com> | 2015-04-10 21:40:59 +0000 |
| commit | aabd7ca452ec652d34b98e428545a9cc55d0db60 (patch) | |
| tree | 14d4ae869befb41641a7de4e537d2a19baebab2d /lld/lib/ReaderWriter | |
| parent | 08d9520f890f71065c4bb088bf5f568491ae8da7 (diff) | |
| download | bcm5719-llvm-aabd7ca452ec652d34b98e428545a9cc55d0db60.tar.gz bcm5719-llvm-aabd7ca452ec652d34b98e428545a9cc55d0db60.zip | |
Do s/_context/_ctx/g globally.
I believe this patch eliminates all remaining uses of _context
or _linkingContext variable names. Consistent naming improves
readability.
llvm-svn: 234645
Diffstat (limited to 'lld/lib/ReaderWriter')
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp | 6 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/GOTPass.cpp | 9 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp | 94 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/ShimPass.cpp | 9 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/StubsPass.cpp | 12 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/MachO/WriterMachO.cpp | 22 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp | 8 | ||||
| -rw-r--r-- | lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp | 8 |
8 files changed, 80 insertions, 88 deletions
diff --git a/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp b/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp index 3bef510ced8..aae81a27cd8 100644 --- a/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp +++ b/lld/lib/ReaderWriter/MachO/CompactUnwindPass.cpp @@ -272,9 +272,9 @@ private: class CompactUnwindPass : public Pass { public: CompactUnwindPass(const MachOLinkingContext &context) - : _context(context), _archHandler(_context.archHandler()), + : _ctx(context), _archHandler(_ctx.archHandler()), _file("<mach-o Compact Unwind Pass>"), - _isBig(MachOLinkingContext::isBigEndian(_context.arch())) {} + _isBig(MachOLinkingContext::isBigEndian(_ctx.arch())) {} private: void perform(std::unique_ptr<SimpleFile> &mergedFile) override { @@ -515,7 +515,7 @@ private: return entry; } - const MachOLinkingContext &_context; + const MachOLinkingContext &_ctx; mach_o::ArchHandler &_archHandler; MachOFile _file; bool _isBig; diff --git a/lld/lib/ReaderWriter/MachO/GOTPass.cpp b/lld/lib/ReaderWriter/MachO/GOTPass.cpp index 5e885c2c620..73505d760b0 100644 --- a/lld/lib/ReaderWriter/MachO/GOTPass.cpp +++ b/lld/lib/ReaderWriter/MachO/GOTPass.cpp @@ -92,8 +92,8 @@ private: class GOTPass : public Pass { public: GOTPass(const MachOLinkingContext &context) - : _context(context), _archHandler(_context.archHandler()), - _file("<mach-o GOT Pass>") { } + : _ctx(context), _archHandler(_ctx.archHandler()), + _file("<mach-o GOT Pass>") {} private: void perform(std::unique_ptr<SimpleFile> &mergedFile) override { @@ -154,7 +154,7 @@ private: auto pos = _targetToGOT.find(target); if (pos == _targetToGOT.end()) { GOTEntryAtom *gotEntry = new (_file.allocator()) - GOTEntryAtom(_file, _context.is64Bit(), target->name()); + GOTEntryAtom(_file, _ctx.is64Bit(), target->name()); _targetToGOT[target] = gotEntry; const ArchHandler::ReferenceInfo &nlInfo = _archHandler.stubInfo(). nonLazyPointerReferenceToBinder; @@ -165,8 +165,7 @@ private: return pos->second; } - - const MachOLinkingContext &_context; + const MachOLinkingContext &_ctx; mach_o::ArchHandler &_archHandler; MachOFile _file; llvm::DenseMap<const Atom*, const GOTEntryAtom*> _targetToGOT; diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp index 0f02f76dd66..d6efc67e627 100644 --- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp +++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp @@ -94,7 +94,7 @@ SegmentInfo::SegmentInfo(StringRef n) class Util { public: Util(const MachOLinkingContext &ctxt) - : _context(ctxt), _archHandler(ctxt.archHandler()), _entryAtom(nullptr) {} + : _ctx(ctxt), _archHandler(ctxt.archHandler()), _entryAtom(nullptr) {} ~Util(); void assignAtomsToSections(const lld::File &atomFile); @@ -156,7 +156,7 @@ private: static unsigned weight(const SectionInfo *); }; - const MachOLinkingContext &_context; + const MachOLinkingContext &_ctx; mach_o::ArchHandler &_archHandler; llvm::BumpPtrAllocator _allocator; std::vector<SectionInfo*> _sectionInfos; @@ -205,9 +205,8 @@ SectionInfo *Util::getRelocatableSection(DefinedAtom::ContentType type) { } } // Otherwise allocate new SectionInfo object. - SectionInfo *sect = new (_allocator) SectionInfo(segmentName, sectionName, - sectionType, _context, - sectionAttrs); + SectionInfo *sect = new (_allocator) + SectionInfo(segmentName, sectionName, sectionType, _ctx, sectionAttrs); _sectionInfos.push_back(sect); _sectionMap[type] = sect; return sect; @@ -276,11 +275,8 @@ SectionInfo *Util::getFinalSection(DefinedAtom::ContentType atomType) { } } // Otherwise allocate new SectionInfo object. - SectionInfo *sect = new (_allocator) SectionInfo(p.segmentName, - p.sectionName, - p.sectionType, - _context, - sectionAttrs); + SectionInfo *sect = new (_allocator) SectionInfo( + p.segmentName, p.sectionName, p.sectionType, _ctx, sectionAttrs); _sectionInfos.push_back(sect); _sectionMap[atomType] = sect; return sect; @@ -297,7 +293,7 @@ SectionInfo *Util::sectionForAtom(const DefinedAtom *atom) { auto pos = _sectionMap.find(type); if ( pos != _sectionMap.end() ) return pos->second; - bool rMode = (_context.outputMachOType() == llvm::MachO::MH_OBJECT); + bool rMode = (_ctx.outputMachOType() == llvm::MachO::MH_OBJECT); return rMode ? getRelocatableSection(type) : getFinalSection(type); } else { // This atom needs to be in a custom section. @@ -314,8 +310,8 @@ 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 = new (_allocator) SectionInfo(segName, sectName, - S_REGULAR, _context); + SectionInfo *sect = + new (_allocator) SectionInfo(segName, sectName, S_REGULAR, _ctx); _customSections.push_back(sect); _sectionInfos.push_back(sect); return sect; @@ -403,14 +399,14 @@ bool Util::TextSectionSorter::operator()(const SectionInfo *left, void Util::organizeSections() { - if (_context.outputMachOType() == llvm::MachO::MH_OBJECT) { + if (_ctx.outputMachOType() == llvm::MachO::MH_OBJECT) { // Leave sections ordered as normalized file specified. uint32_t sectionIndex = 1; for (SectionInfo *si : _sectionInfos) { si->finalSectionIndex = sectionIndex++; } } else { - switch (_context.outputMachOType()){ + switch (_ctx.outputMachOType()) { case llvm::MachO::MH_EXECUTE: // Main executables, need a zero-page segment segmentForName("__PAGEZERO"); @@ -459,7 +455,7 @@ void Util::layoutSectionsInSegment(SegmentInfo *seg, uint64_t &addr) { sect->address = llvm::RoundUpToAlignment(addr, sect->alignment); addr = sect->address + sect->size; } - seg->size = llvm::RoundUpToAlignment(addr - seg->address,_context.pageSize()); + seg->size = llvm::RoundUpToAlignment(addr - seg->address, _ctx.pageSize()); } @@ -476,35 +472,35 @@ void Util::layoutSectionsInTextSegment(size_t hlcSize, SegmentInfo *seg, } int64_t padding = taddr - hlcSize; while (padding < 0) - padding += _context.pageSize(); + padding += _ctx.pageSize(); // Start assigning section address starting at padded offset. addr += (padding + hlcSize); for (SectionInfo *sect : seg->sections) { sect->address = llvm::RoundUpToAlignment(addr, sect->alignment); addr = sect->address + sect->size; } - seg->size = llvm::RoundUpToAlignment(addr - seg->address,_context.pageSize()); + seg->size = llvm::RoundUpToAlignment(addr - seg->address, _ctx.pageSize()); } void Util::assignAddressesToSections(const NormalizedFile &file) { size_t hlcSize = headerAndLoadCommandsSize(file); uint64_t address = 0; - if (_context.outputMachOType() != llvm::MachO::MH_OBJECT) { + if (_ctx.outputMachOType() != llvm::MachO::MH_OBJECT) { for (SegmentInfo *seg : _segmentInfos) { if (seg->name.equals("__PAGEZERO")) { - seg->size = _context.pageZeroSize(); + seg->size = _ctx.pageZeroSize(); address += seg->size; } else if (seg->name.equals("__TEXT")) { - // _context.baseAddress() == 0 implies it was either unspecified or + // _ctx.baseAddress() == 0 implies it was either unspecified or // pageZeroSize is also 0. In either case resetting address is safe. - address = _context.baseAddress() ? _context.baseAddress() : address; + address = _ctx.baseAddress() ? _ctx.baseAddress() : address; layoutSectionsInTextSegment(hlcSize, seg, address); } else layoutSectionsInSegment(seg, address); - address = llvm::RoundUpToAlignment(address, _context.pageSize()); + address = llvm::RoundUpToAlignment(address, _ctx.pageSize()); } DEBUG_WITH_TYPE("WriterMachO-norm", llvm::dbgs() << "assignAddressesToSections()\n"; @@ -567,7 +563,7 @@ void Util::appendSection(SectionInfo *si, NormalizedFile &file) { } void Util::copySectionContent(NormalizedFile &file) { - const bool r = (_context.outputMachOType() == llvm::MachO::MH_OBJECT); + const bool r = (_ctx.outputMachOType() == llvm::MachO::MH_OBJECT); // Utility function for ArchHandler to find address of atom in output file. auto addrForAtom = [&] (const Atom &atom) -> uint64_t { @@ -598,8 +594,8 @@ void Util::copySectionContent(NormalizedFile &file) { uint8_t *atomContent = reinterpret_cast<uint8_t*> (§ionContent[ai.offsetInSection]); _archHandler.generateAtomContent(*ai.atom, r, addrForAtom, - sectionAddrForAtom, - _context.baseAddress(), atomContent); + sectionAddrForAtom, _ctx.baseAddress(), + atomContent); } } } @@ -608,7 +604,7 @@ void Util::copySectionContent(NormalizedFile &file) { void Util::copySectionInfo(NormalizedFile &file) { file.sections.reserve(_sectionInfos.size()); // For final linked images, write sections grouped by segment. - if (_context.outputMachOType() != llvm::MachO::MH_OBJECT) { + if (_ctx.outputMachOType() != llvm::MachO::MH_OBJECT) { for (SegmentInfo *sgi : _segmentInfos) { for (SectionInfo *si : sgi->sections) { appendSection(si, file); @@ -624,7 +620,7 @@ void Util::copySectionInfo(NormalizedFile &file) { void Util::updateSectionInfo(NormalizedFile &file) { file.sections.reserve(_sectionInfos.size()); - if (_context.outputMachOType() != llvm::MachO::MH_OBJECT) { + if (_ctx.outputMachOType() != llvm::MachO::MH_OBJECT) { // For final linked images, sections grouped by segment. for (SegmentInfo *sgi : _segmentInfos) { Segment *normSeg = &file.segments[sgi->normalizedSegmentIndex]; @@ -645,7 +641,7 @@ void Util::updateSectionInfo(NormalizedFile &file) { } void Util::copyEntryPointAddress(NormalizedFile &nFile) { - if (_context.outputTypeHasEntry()) { + if (_ctx.outputTypeHasEntry()) { if (_archHandler.isThumbFunction(*_entryAtom)) nFile.entryAddress = (_atomToAddress[_entryAtom] | 1); else @@ -656,13 +652,13 @@ void Util::copyEntryPointAddress(NormalizedFile &nFile) { void Util::buildAtomToAddressMap() { DEBUG_WITH_TYPE("WriterMachO-address", llvm::dbgs() << "assign atom addresses:\n"); - const bool lookForEntry = _context.outputTypeHasEntry(); + const bool lookForEntry = _ctx.outputTypeHasEntry(); for (SectionInfo *sect : _sectionInfos) { for (const AtomInfo &info : sect->atomsAndOffsets) { _atomToAddress[info.atom] = sect->address + info.offsetInSection; if (lookForEntry && (info.atom->contentType() == DefinedAtom::typeCode) && (info.atom->size() != 0) && - info.atom->name() == _context.entrySymbolName()) { + info.atom->name() == _ctx.entrySymbolName()) { _entryAtom = info.atom; } DEBUG_WITH_TYPE("WriterMachO-address", llvm::dbgs() @@ -673,7 +669,7 @@ void Util::buildAtomToAddressMap() { } } for (const Atom *atom : _machHeaderAliasAtoms) { - _atomToAddress[atom] = _context.baseAddress(); + _atomToAddress[atom] = _ctx.baseAddress(); DEBUG_WITH_TYPE("WriterMachO-address", llvm::dbgs() << " address=" << llvm::format("0x%016X", _atomToAddress[atom]) @@ -720,20 +716,20 @@ bool Util::AtomSorter::operator()(const AtomAndIndex &left, std::error_code Util::getSymbolTableRegion(const DefinedAtom* atom, bool &inGlobalsRegion, SymbolScope &scope) { - bool rMode = (_context.outputMachOType() == llvm::MachO::MH_OBJECT); + bool rMode = (_ctx.outputMachOType() == llvm::MachO::MH_OBJECT); switch (atom->scope()) { case Atom::scopeTranslationUnit: scope = 0; inGlobalsRegion = false; return std::error_code(); case Atom::scopeLinkageUnit: - if ((_context.exportMode() == MachOLinkingContext::ExportMode::whiteList) - && _context.exportSymbolNamed(atom->name())) { + if ((_ctx.exportMode() == MachOLinkingContext::ExportMode::whiteList) && + _ctx.exportSymbolNamed(atom->name())) { return make_dynamic_error_code(Twine("cannot export hidden symbol ") + atom->name()); } if (rMode) { - if (_context.keepPrivateExterns()) { + if (_ctx.keepPrivateExterns()) { // -keep_private_externs means keep in globals region as N_PEXT. scope = N_PEXT | N_EXT; inGlobalsRegion = true; @@ -745,8 +741,8 @@ std::error_code Util::getSymbolTableRegion(const DefinedAtom* atom, inGlobalsRegion = false; return std::error_code(); case Atom::scopeGlobal: - if (_context.exportRestrictMode()) { - if (_context.exportSymbolNamed(atom->name())) { + if (_ctx.exportRestrictMode()) { + if (_ctx.exportSymbolNamed(atom->name())) { scope = N_EXT; inGlobalsRegion = true; return std::error_code(); @@ -767,7 +763,7 @@ std::error_code Util::getSymbolTableRegion(const DefinedAtom* atom, std::error_code Util::addSymbols(const lld::File &atomFile, NormalizedFile &file) { - bool rMode = (_context.outputMachOType() == llvm::MachO::MH_OBJECT); + bool rMode = (_ctx.outputMachOType() == llvm::MachO::MH_OBJECT); // Mach-O symbol table has three regions: locals, globals, undefs. // Add all local (non-global) symbols in address order @@ -953,8 +949,8 @@ void Util::addDependentDylibs(const lld::File &atomFile,NormalizedFile &nFile) { DependentDylib depInfo; depInfo.path = loadPath; depInfo.kind = llvm::MachO::LC_LOAD_DYLIB; - depInfo.currentVersion = _context.dylibCurrentVersion(loadPath); - depInfo.compatVersion = _context.dylibCompatVersion(loadPath); + depInfo.currentVersion = _ctx.dylibCurrentVersion(loadPath); + depInfo.compatVersion = _ctx.dylibCompatVersion(loadPath); nFile.dependentDylibs.push_back(depInfo); } else { if ( slAtom->canBeNullAtRuntime() ) @@ -968,7 +964,7 @@ void Util::addDependentDylibs(const lld::File &atomFile,NormalizedFile &nFile) { DylibInfo &info = _dylibInfo[dep.path]; if (info.hasWeak && !info.hasNonWeak) dep.kind = llvm::MachO::LC_LOAD_WEAK_DYLIB; - else if (_context.isUpwardDylib(dep.path)) + else if (_ctx.isUpwardDylib(dep.path)) dep.kind = llvm::MachO::LC_LOAD_UPWARD_DYLIB; } } @@ -1005,7 +1001,7 @@ uint32_t Util::sectionIndexForAtom(const Atom *atom) { } void Util::addSectionRelocs(const lld::File &, NormalizedFile &file) { - if (_context.outputMachOType() != llvm::MachO::MH_OBJECT) + if (_ctx.outputMachOType() != llvm::MachO::MH_OBJECT) return; @@ -1085,7 +1081,7 @@ void Util::buildDataInCodeArray(const lld::File &, NormalizedFile &file) { void Util::addRebaseAndBindingInfo(const lld::File &atomFile, NormalizedFile &nFile) { - if (_context.outputMachOType() == llvm::MachO::MH_OBJECT) + if (_ctx.outputMachOType() == llvm::MachO::MH_OBJECT) return; uint8_t segmentIndex; @@ -1141,7 +1137,7 @@ void Util::addRebaseAndBindingInfo(const lld::File &atomFile, } void Util::addExportInfo(const lld::File &atomFile, NormalizedFile &nFile) { - if (_context.outputMachOType() == llvm::MachO::MH_OBJECT) + if (_ctx.outputMachOType() == llvm::MachO::MH_OBJECT) return; for (SectionInfo *sect : _sectionInfos) { @@ -1149,8 +1145,8 @@ void Util::addExportInfo(const lld::File &atomFile, NormalizedFile &nFile) { const DefinedAtom *atom = info.atom; if (atom->scope() != Atom::scopeGlobal) continue; - if (_context.exportRestrictMode()) { - if (!_context.exportSymbolNamed(atom->name())) + if (_ctx.exportRestrictMode()) { + if (!_ctx.exportSymbolNamed(atom->name())) continue; } Export exprt; @@ -1170,10 +1166,10 @@ void Util::addExportInfo(const lld::File &atomFile, NormalizedFile &nFile) { uint32_t Util::fileFlags() { // FIXME: these need to determined at runtime. - if (_context.outputMachOType() == MH_OBJECT) { + if (_ctx.outputMachOType() == MH_OBJECT) { return MH_SUBSECTIONS_VIA_SYMBOLS; } else { - if ((_context.outputMachOType() == MH_EXECUTE) && _context.PIE()) + if ((_ctx.outputMachOType() == MH_EXECUTE) && _ctx.PIE()) return MH_DYLDLINK | MH_NOUNDEFS | MH_TWOLEVEL | MH_PIE; else return MH_DYLDLINK | MH_NOUNDEFS | MH_TWOLEVEL; diff --git a/lld/lib/ReaderWriter/MachO/ShimPass.cpp b/lld/lib/ReaderWriter/MachO/ShimPass.cpp index 8d53c230b7d..6268ba60aae 100644 --- a/lld/lib/ReaderWriter/MachO/ShimPass.cpp +++ b/lld/lib/ReaderWriter/MachO/ShimPass.cpp @@ -41,11 +41,8 @@ namespace mach_o { class ShimPass : public Pass { public: ShimPass(const MachOLinkingContext &context) - : _context(context) - , _archHandler(_context.archHandler()) - , _stubInfo(_archHandler.stubInfo()) - , _file("<mach-o shim pass>") { - } + : _ctx(context), _archHandler(_ctx.archHandler()), + _stubInfo(_archHandler.stubInfo()), _file("<mach-o shim pass>") {} void perform(std::unique_ptr<SimpleFile> &mergedFile) override { // Scan all references in all atoms. @@ -111,7 +108,7 @@ private: } } - const MachOLinkingContext &_context; + const MachOLinkingContext &_ctx; mach_o::ArchHandler &_archHandler; const ArchHandler::StubInfo &_stubInfo; MachOFile _file; diff --git a/lld/lib/ReaderWriter/MachO/StubsPass.cpp b/lld/lib/ReaderWriter/MachO/StubsPass.cpp index 5c4bb2cccf4..f0b792c4d2e 100644 --- a/lld/lib/ReaderWriter/MachO/StubsPass.cpp +++ b/lld/lib/ReaderWriter/MachO/StubsPass.cpp @@ -206,8 +206,8 @@ private: class StubsPass : public Pass { public: StubsPass(const MachOLinkingContext &context) - : _context(context), _archHandler(_context.archHandler()), - _stubInfo(_archHandler.stubInfo()), _file("<mach-o Stubs pass>") { } + : _ctx(context), _archHandler(_ctx.archHandler()), + _stubInfo(_archHandler.stubInfo()), _file("<mach-o Stubs pass>") {} void perform(std::unique_ptr<SimpleFile> &mergedFile) override { // Skip this pass if output format uses text relocations instead of stubs. @@ -245,9 +245,9 @@ public: SimpleDefinedAtom *helperCommonAtom = new (_file.allocator()) StubHelperCommonAtom(_file, _stubInfo); SimpleDefinedAtom *helperCacheNLPAtom = - new (_file.allocator()) NonLazyPointerAtom(_file, _context.is64Bit()); + new (_file.allocator()) NonLazyPointerAtom(_file, _ctx.is64Bit()); SimpleDefinedAtom *helperBinderNLPAtom = - new (_file.allocator()) NonLazyPointerAtom(_file, _context.is64Bit()); + new (_file.allocator()) NonLazyPointerAtom(_file, _ctx.is64Bit()); addReference(helperCommonAtom, _stubInfo.stubHelperCommonReferenceToCache, helperCacheNLPAtom); addOptReference( @@ -285,7 +285,7 @@ public: for (const Atom *target : targetsNeedingStubs) { StubAtom *stub = new (_file.allocator()) StubAtom(_file, _stubInfo); LazyPointerAtom *lp = - new (_file.allocator()) LazyPointerAtom(_file, _context.is64Bit()); + new (_file.allocator()) LazyPointerAtom(_file, _ctx.is64Bit()); StubHelperAtom *helper = new (_file.allocator()) StubHelperAtom(_file, _stubInfo); @@ -355,7 +355,7 @@ private: typedef llvm::DenseMap<const Atom*, llvm::SmallVector<const Reference *, 8>> TargetToUses; - const MachOLinkingContext &_context; + const MachOLinkingContext &_ctx; mach_o::ArchHandler &_archHandler; const ArchHandler::StubInfo &_stubInfo; MachOFile _file; diff --git a/lld/lib/ReaderWriter/MachO/WriterMachO.cpp b/lld/lib/ReaderWriter/MachO/WriterMachO.cpp index 35dce8fbaf2..3ed32bba109 100644 --- a/lld/lib/ReaderWriter/MachO/WriterMachO.cpp +++ b/lld/lib/ReaderWriter/MachO/WriterMachO.cpp @@ -26,18 +26,18 @@ namespace mach_o { class MachOWriter : public Writer { public: - MachOWriter(const MachOLinkingContext &ctxt) : _context(ctxt) { } + MachOWriter(const MachOLinkingContext &ctxt) : _ctx(ctxt) {} std::error_code writeFile(const lld::File &file, StringRef path) override { // Construct empty normalized file from atoms. ErrorOr<std::unique_ptr<NormalizedFile>> nFile = - normalized::normalizedFromAtoms(file, _context); + normalized::normalizedFromAtoms(file, _ctx); if (std::error_code ec = nFile.getError()) return ec; // For testing, write out yaml form of normalized file. - if (_context.printAtoms()) { - std::unique_ptr<Writer> yamlWriter = createWriterYAML(_context); + if (_ctx.printAtoms()) { + std::unique_ptr<Writer> yamlWriter = createWriterYAML(_ctx); yamlWriter->writeFile(file, "-"); } @@ -47,17 +47,17 @@ public: void createImplicitFiles(std::vector<std::unique_ptr<File>> &r) override { // When building main executables, add _main as required entry point. - if (_context.outputTypeHasEntry()) - r.emplace_back(new CEntryFile(_context)); + if (_ctx.outputTypeHasEntry()) + r.emplace_back(new CEntryFile(_ctx)); // If this can link with dylibs, need helper function (dyld_stub_binder). - if (_context.needsStubsPass()) - r.emplace_back(new StubHelperFile(_context)); + if (_ctx.needsStubsPass()) + r.emplace_back(new StubHelperFile(_ctx)); // Final linked images can access a symbol for their mach_header. - if (_context.outputMachOType() != llvm::MachO::MH_OBJECT) - r.emplace_back(new MachHeaderAliasFile(_context)); + if (_ctx.outputMachOType() != llvm::MachO::MH_OBJECT) + r.emplace_back(new MachHeaderAliasFile(_ctx)); } private: - const MachOLinkingContext &_context; + const MachOLinkingContext &_ctx; }; diff --git a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp index 76b85b03cb8..8c3aac04f8f 100644 --- a/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp +++ b/lld/lib/ReaderWriter/PECOFF/WriterPECOFF.cpp @@ -104,15 +104,15 @@ public: class DOSStubChunk : public HeaderChunk { public: explicit DOSStubChunk(const PECOFFLinkingContext &ctx) - : HeaderChunk(), _context(ctx) { + : HeaderChunk(), _ctx(ctx) { // Minimum size of DOS stub is 64 bytes. The next block (PE header) needs to // be aligned on 8 byte boundary. - size_t size = std::max(_context.getDosStub().size(), (size_t)64); + size_t size = std::max(_ctx.getDosStub().size(), (size_t)64); _size = llvm::RoundUpToAlignment(size, 8); } void write(uint8_t *buffer) override { - ArrayRef<uint8_t> array = _context.getDosStub(); + ArrayRef<uint8_t> array = _ctx.getDosStub(); std::memcpy(buffer, array.data(), array.size()); auto *header = reinterpret_cast<llvm::object::dos_header *>(buffer); header->AddressOfRelocationTable = sizeof(llvm::object::dos_header); @@ -120,7 +120,7 @@ public: } private: - const PECOFFLinkingContext &_context; + const PECOFFLinkingContext &_ctx; }; /// A PEHeaderChunk represents PE header including COFF header. diff --git a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp index cedccddaa3a..eccb099415d 100644 --- a/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp +++ b/lld/lib/ReaderWriter/YAML/ReaderWriterYAML.cpp @@ -1230,7 +1230,7 @@ namespace yaml { class Writer : public lld::Writer { public: - Writer(const LinkingContext &context) : _context(context) {} + Writer(const LinkingContext &context) : _ctx(context) {} std::error_code writeFile(const lld::File &file, StringRef outPath) override { // Create stream to path. @@ -1241,8 +1241,8 @@ public: // Create yaml Output writer, using yaml options for context. YamlContext yamlContext; - yamlContext._linkingContext = &_context; - yamlContext._registry = &_context.registry(); + yamlContext._ctx = &_ctx; + yamlContext._registry = &_ctx.registry(); llvm::yaml::Output yout(out, &yamlContext); // Write yaml output. @@ -1253,7 +1253,7 @@ public: } private: - const LinkingContext &_context; + const LinkingContext &_ctx; }; } // end namespace yaml |

