Index: COFF/Driver.cpp =================================================================== --- COFF/Driver.cpp +++ COFF/Driver.cpp @@ -14,19 +14,30 @@ #include "SymbolTable.h" #include "Symbols.h" #include "Writer.h" +#include "lld/Core/LLVM.h" #include "lld/Driver/Driver.h" +#include "llvm/ADT/None.h" #include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/SmallVector.h" +#include "llvm/ADT/Twine.h" #include "llvm/LibDriver/LibDriver.h" #include "llvm/Option/Arg.h" #include "llvm/Option/ArgList.h" #include "llvm/Option/Option.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/Path.h" #include "llvm/Support/Process.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" #include +#include +#include #include +#include +#include using namespace llvm; using namespace llvm::COFF; @@ -278,9 +289,9 @@ error("no input files."); // Construct search path list. - SearchPaths.push_back(""); + SearchPaths.emplace_back(""); for (auto *Arg : Args.filtered(OPT_libpath)) - SearchPaths.push_back(Arg->getValue()); + SearchPaths.emplace_back(Arg->getValue()); addLibSearchPaths(); // Handle /out Index: ELF/Driver.cpp =================================================================== --- ELF/Driver.cpp +++ ELF/Driver.cpp @@ -19,11 +19,23 @@ #include "Target.h" #include "Writer.h" #include "lld/Driver/Driver.h" +#include "llvm/ADT/None.h" +#include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/Object/Archive.h" +#include "llvm/Object/ELFTypes.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/CommandLine.h" +#include "llvm/Support/ELF.h" +#include "llvm/Support/ErrorOr.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/TargetSelect.h" #include "llvm/Support/raw_ostream.h" +#include +#include #include +#include #include using namespace llvm; @@ -298,11 +310,11 @@ // Initializes Config members by the command line options. void LinkerDriver::readConfigs(opt::InputArgList &Args) { for (auto *Arg : Args.filtered(OPT_L)) - Config->SearchPaths.push_back(Arg->getValue()); + Config->SearchPaths.emplace_back(Arg->getValue()); std::vector RPaths; for (auto *Arg : Args.filtered(OPT_rpath)) - RPaths.push_back(Arg->getValue()); + RPaths.emplace_back(Arg->getValue()); if (!RPaths.empty()) Config->RPath = llvm::join(RPaths.begin(), RPaths.end(), ":"); @@ -412,14 +424,14 @@ } for (auto *Arg : Args.filtered(OPT_undefined)) - Config->Undefined.push_back(Arg->getValue()); + Config->Undefined.emplace_back(Arg->getValue()); if (auto *Arg = Args.getLastArg(OPT_dynamic_list)) if (Optional Buffer = readFile(Arg->getValue())) parseDynamicList(*Buffer); for (auto *Arg : Args.filtered(OPT_export_dynamic_symbol)) - Config->DynamicList.push_back(Arg->getValue()); + Config->DynamicList.emplace_back(Arg->getValue()); if (auto *Arg = Args.getLastArg(OPT_version_script)) { if (Optional Buffer = readFile(Arg->getValue())) Index: ELF/InputFiles.cpp =================================================================== --- ELF/InputFiles.cpp +++ ELF/InputFiles.cpp @@ -13,11 +13,26 @@ #include "InputSection.h" #include "SymbolTable.h" #include "Symbols.h" +#include "llvm/ADT/SmallString.h" #include "llvm/ADT/STLExtras.h" +#include "llvm/ADT/iterator_range.h" #include "llvm/CodeGen/Analysis.h" +#include "llvm/IR/DataLayout.h" +#include "llvm/IR/GlobalValue.h" #include "llvm/IR/LLVMContext.h" #include "llvm/IR/Module.h" +#include "llvm/Object/SymbolicFile.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/ErrorHandling.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include +#include +#include +#include using namespace llvm; using namespace llvm::ELF; @@ -750,7 +765,7 @@ SmallString<64> Name; raw_svector_ostream OS(Name); Sym.printName(OS); - V.push_back(Saver.save(StringRef(Name))); + V.emplace_back(Saver.save(StringRef(Name))); } return V; } Index: ELF/OutputSections.cpp =================================================================== --- ELF/OutputSections.cpp +++ ELF/OutputSections.cpp @@ -10,15 +10,28 @@ #include "OutputSections.h" #include "Config.h" #include "EhFrame.h" +#include "Error.h" +#include "InputFiles.h" +#include "InputSection.h" #include "LinkerScript.h" +#include "Symbols.h" #include "SymbolTable.h" #include "Target.h" #include "lld/Core/Parallel.h" +#include "llvm/ADT/DenseMapInfo.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/Dwarf.h" +#include "llvm/Support/ELF.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MD5.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/SHA1.h" -#include +#include +#include +#include +#include +#include using namespace llvm; using namespace llvm::dwarf; @@ -335,7 +348,7 @@ template void PltSection::addEntry(SymbolBody &Sym) { Sym.PltIndex = Entries.size(); unsigned RelOff = Out::RelaPlt->getRelocOffset(); - Entries.push_back(std::make_pair(&Sym, RelOff)); + Entries.emplace_back(&Sym, RelOff); } template void PltSection::finalize() { @@ -607,7 +620,7 @@ V.erase(Mid, V.end()); for (const SymbolData &Sym : Symbols) - V.push_back({Sym.Body, Sym.STName}); + V.emplace_back(Sym.Body, Sym.STName); } // Returns the number of version definition entries. Because the first entry @@ -880,7 +893,7 @@ std::vector V; for (InputSection *S : Sections) - V.push_back({getPriority(S->getSectionName()), S}); + V.emplace_back(getPriority(S->getSectionName()), S); std::stable_sort(V.begin(), V.end(), Comp); Sections.clear(); for (Pair &P : V) @@ -1378,7 +1391,7 @@ template void SymbolTableSection::addSymbol(SymbolBody *B) { - Symbols.push_back({B, StrTabSec.addString(B->getName(), false)}); + Symbols.emplace_back(B, StrTabSec.addString(B->getName(), false)); } template void SymbolTableSection::writeTo(uint8_t *Buf) { @@ -1611,7 +1624,7 @@ // to create one by adding it to our needed list and creating a dynstr entry // for the soname. if (F->VerdefMap.empty()) - Needed.push_back({F, Out::DynStrTab->addString(F->getSoName())}); + Needed.emplace_back(F, Out::DynStrTab->addString(F->getSoName())); typename SharedFile::NeededVer &NV = F->VerdefMap[SS->Verdef]; // If we don't already know that we need an Elf_Vernaux for this Elf_Verdef, // prepare to create one by allocating a version identifier and creating a @@ -1782,6 +1795,7 @@ namespace lld { namespace elf { + template class OutputSectionBase; template class OutputSectionBase; template class OutputSectionBase; @@ -1906,5 +1920,6 @@ template class BuildIdHexstring; template class BuildIdHexstring; template class BuildIdHexstring; -} -} + +} // namespace elf +} // namespace lld Index: ELF/Writer.cpp =================================================================== --- ELF/Writer.cpp +++ ELF/Writer.cpp @@ -9,17 +9,40 @@ #include "Writer.h" #include "Config.h" +#include "Error.h" +#include "InputFiles.h" +#include "InputSection.h" #include "LinkerScript.h" #include "OutputSections.h" #include "Relocations.h" +#include "Symbols.h" #include "SymbolTable.h" #include "Target.h" - -#include "llvm/ADT/StringMap.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h" +#include "llvm/ADT/DenseMapInfo.h" +#include "llvm/ADT/Hashing.h" +#include "llvm/ADT/StringRef.h" #include "llvm/ADT/StringSwitch.h" +#include "llvm/Support/Allocator.h" +#include "llvm/Support/Casting.h" +#include "llvm/Support/ELF.h" +#include "llvm/Support/Endian.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/FileOutputBuffer.h" +#include "llvm/Support/MathExtras.h" #include "llvm/Support/StringSaver.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include using namespace llvm; using namespace llvm::ELF; @@ -39,6 +62,7 @@ typedef typename ELFT::Sym Elf_Sym; typedef typename ELFT::SymRange Elf_Sym_Range; typedef typename ELFT::Rela Elf_Rela; + Writer(SymbolTable &S) : Symtab(S) {} void run(); @@ -75,9 +99,11 @@ void writeBuildId(); bool isDiscarded(InputSectionBase *IS) const; StringRef getOutputSectionName(InputSectionBase *S) const; + bool needsInterpSection() const { return !Symtab.getSharedFiles().empty() && !Config->DynamicLinker.empty(); } + bool isOutputDynamic() const { return !Symtab.getSharedFiles().empty() || Config->Pic; } @@ -249,20 +275,24 @@ uintX_t Flags; uintX_t Alignment; }; -} +} // anonymous namespace + namespace llvm { template struct DenseMapInfo> { static SectionKey getEmptyKey() { return SectionKey{DenseMapInfo::getEmptyKey(), 0, 0, 0}; } + static SectionKey getTombstoneKey() { return SectionKey{DenseMapInfo::getTombstoneKey(), 0, 0, 0}; } + static unsigned getHashValue(const SectionKey &Val) { return hash_combine(Val.Name, Val.Type, Val.Flags, Val.Alignment); } + static bool isEqual(const SectionKey &LHS, const SectionKey &RHS) { return DenseMapInfo::isEqual(LHS.Name, RHS.Name) && @@ -270,7 +300,7 @@ LHS.Alignment == RHS.Alignment; } }; -} +} // namespace llvm template static void reportUndefined(SymbolTable &Symtab, SymbolBody *Sym) { @@ -361,8 +391,8 @@ ++Out::SymTab->NumLocals; if (Config->Relocatable) B->DynsymIndex = Out::SymTab->NumLocals; - F->KeptLocalSyms.push_back( - std::make_pair(DR, Out::SymTab->StrTabSec.addString(SymName))); + F->KeptLocalSyms.emplace_back( + DR, Out::SymTab->StrTabSec.addString(SymName)); } } } @@ -586,7 +616,7 @@ SmallDenseMap, OutputSectionBase *> Map; }; -} +} // anonymous namespace template std::pair *, bool> @@ -1374,10 +1404,10 @@ for (OutputSectionBase *Sec : OutputSections) { uint8_t *End = Start + Sec->getFileOff(); if (!Sec->getName().startswith(".debug_")) - Regions.push_back({Last, End}); + Regions.emplace_back(Last, End); Last = End; } - Regions.push_back({Last, Start + FileSize}); + Regions.emplace_back(Last, Start + FileSize); S->writeBuildId(Regions); } Index: lib/Driver/DarwinLdDriver.cpp =================================================================== --- lib/Driver/DarwinLdDriver.cpp +++ lib/Driver/DarwinLdDriver.cpp @@ -14,24 +14,45 @@ //===----------------------------------------------------------------------===// #include "lld/Core/ArchiveLibraryFile.h" +#include "lld/Core/Error.h" #include "lld/Core/File.h" #include "lld/Core/Instrumentation.h" +#include "lld/Core/LinkingContext.h" +#include "lld/Core/Node.h" #include "lld/Core/PassManager.h" #include "lld/Core/Resolver.h" #include "lld/Core/SharedLibraryFile.h" +#include "lld/Core/Simple.h" #include "lld/Driver/Driver.h" #include "lld/ReaderWriter/MachOLinkingContext.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/Optional.h" +#include "llvm/ADT/SmallString.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/StringExtras.h" -#include "llvm/ADT/Triple.h" +#include "llvm/ADT/StringRef.h" +#include "llvm/ADT/Twine.h" #include "llvm/Option/Arg.h" +#include "llvm/Option/ArgList.h" #include "llvm/Option/Option.h" +#include "llvm/Option/OptTable.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/CommandLine.h" #include "llvm/Support/Error.h" +#include "llvm/Support/ErrorOr.h" #include "llvm/Support/Format.h" +#include "llvm/Support/MachO.h" +#include "llvm/Support/MathExtras.h" +#include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include +#include +#include +#include +#include using namespace lld; @@ -166,8 +187,6 @@ return std::error_code(); } - - /// Order files are one symbol per line. Blank lines are ignored. /// Trailing comments start with #. Symbol names can be prefixed with an /// architecture name and/or .o leaf name. Examples: @@ -589,7 +608,7 @@ // 4. If { syslibroots } x path == {}, the original path is kept. std::vector sysLibRoots; for (auto syslibRoot : parsedArgs.filtered(OPT_syslibroot)) { - sysLibRoots.push_back(syslibRoot->getValue()); + sysLibRoots.emplace_back(syslibRoot->getValue()); } if (!sysLibRoots.empty()) { // Ignore all if last -syslibroot is "/". @@ -1211,5 +1230,6 @@ return true; } + } // namespace mach_o } // namespace lld Index: lib/ReaderWriter/MachO/CompactUnwindPass.cpp =================================================================== --- lib/ReaderWriter/MachO/CompactUnwindPass.cpp +++ lib/ReaderWriter/MachO/CompactUnwindPass.cpp @@ -16,15 +16,25 @@ #include "ArchHandler.h" #include "File.h" #include "MachONormalizedFileBinaryUtils.h" -#include "MachOPasses.h" #include "lld/Core/DefinedAtom.h" -#include "lld/Core/File.h" #include "lld/Core/LLVM.h" +#include "lld/Core/Pass.h" +#include "lld/Core/PassManager.h" #include "lld/Core/Reference.h" #include "lld/Core/Simple.h" -#include "llvm/ADT/DenseMap.h" +#include "lld/ReaderWriter/MachOLinkingContext.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/STLExtras.h" +#include "llvm/Support/Casting.h" #include "llvm/Support/Debug.h" -#include "llvm/Support/Format.h" +#include "llvm/Support/Error.h" +#include +#include +#include +#include +#include +#include +#include #define DEBUG_TYPE "macho-compact-unwind" @@ -61,7 +71,7 @@ struct UnwindInfoPage { ArrayRef entries; }; -} +} // end anonymous namespace class UnwindInfoAtom : public SimpleDefinedAtom { public: @@ -327,7 +337,7 @@ std::vector pages; auto remainingInfos = llvm::makeArrayRef(unwindInfos); do { - pages.push_back(UnwindInfoPage()); + pages.emplace_back(); // FIXME: we only create regular pages at the moment. These can hold up to // 1021 entries according to the documentation. @@ -514,10 +524,8 @@ // Finally, delete all unreferenced CFI atoms. mergedFile.removeDefinedAtomsIf([&](const DefinedAtom *atom) { - if ((atom->contentType() == DefinedAtom::typeCFI) && - !usedDwarfFrames.count(atom)) - return true; - return false; + return ((atom->contentType() == DefinedAtom::typeCFI) && + !usedDwarfFrames.count(atom)); }); } @@ -537,7 +545,6 @@ } else entry = unwindLoc->second; - // If there's no __compact_unwind entry, or it explicitly says to use // __eh_frame, we need to try and fill in the correct DWARF atom. if (entry.encoding == _archHandler.dwarfCompactUnwindType() || @@ -578,5 +585,5 @@ pm.add(llvm::make_unique(ctx)); } -} // end namesapce mach_o -} // end namesapce lld +} // end namespace mach_o +} // end namespace lld Index: lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp =================================================================== --- lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp +++ lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp @@ -23,25 +23,30 @@ #include "MachONormalizedFile.h" #include "ArchHandler.h" +#include "File.h" #include "MachONormalizedFileBinaryUtils.h" #include "lld/Core/Error.h" -#include "lld/Core/LLVM.h" -#include "lld/Core/SharedLibraryFile.h" -#include "llvm/ADT/SmallString.h" +#include "lld/Core/Reader.h" +#include "lld/Core/Reference.h" +#include "lld/ReaderWriter/MachOLinkingContext.h" +#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/StringRef.h" -#include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Twine.h" #include "llvm/Object/MachO.h" -#include "llvm/Support/Casting.h" #include "llvm/Support/Errc.h" -#include "llvm/Support/ErrorHandling.h" -#include "llvm/Support/FileOutputBuffer.h" +#include "llvm/Support/Error.h" +#include "llvm/Support/ErrorOr.h" +#include "llvm/Support/FileSystem.h" #include "llvm/Support/Host.h" #include "llvm/Support/MachO.h" #include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/raw_ostream.h" +#include "llvm/Support/SwapByteOrder.h" +#include +#include +#include #include +#include #include using namespace llvm::MachO; @@ -109,14 +114,12 @@ return std::error_code(); } - template static T readBigEndian(T t) { if (llvm::sys::IsLittleEndianHost) llvm::sys::swapByteOrder(t); return t; } - static bool isMachOHeader(const mach_header *mh, bool &is64, bool &isBig) { switch (read32(&mh->magic, false)) { case llvm::MachO::MH_MAGIC: @@ -140,7 +143,6 @@ } } - bool isThinObjectFile(StringRef path, MachOLinkingContext::Arch &arch) { // Try opening and mapping file at path. ErrorOr> b = MemoryBuffer::getFileOrSTDIN(path); @@ -465,7 +467,7 @@ break; case LC_RPATH: { const rpath_command *rpc = reinterpret_cast(lc); - f->rpaths.push_back(lc + read32(&rpc->path, isBig)); + f->rpaths.emplace_back(lc + read32(&rpc->path, isBig)); } break; case LC_DYLD_INFO: @@ -582,5 +584,4 @@ new mach_o::MachOYamlIOTaggedDocumentHandler(arch))); } - } // namespace lld Index: lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp =================================================================== --- lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp +++ lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp @@ -17,23 +17,29 @@ #include "MachONormalizedFile.h" #include "lld/Core/Error.h" -#include "lld/Core/LLVM.h" +#include "lld/ReaderWriter/MachOLinkingContext.h" #include "lld/ReaderWriter/YamlContext.h" -#include "llvm/ADT/SmallString.h" +#include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/None.h" #include "llvm/ADT/StringRef.h" -#include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Twine.h" -#include "llvm/Support/Casting.h" +#include "llvm/Support/Error.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Format.h" #include "llvm/Support/MachO.h" +#include "llvm/Support/MathExtras.h" #include "llvm/Support/MemoryBuffer.h" -#include "llvm/Support/SourceMgr.h" #include "llvm/Support/YAMLTraits.h" #include "llvm/Support/raw_ostream.h" +#include +#include +#include +#include +#include +#include #include +#include - using llvm::StringRef; using namespace llvm::yaml; using namespace llvm::MachO; @@ -48,7 +54,6 @@ LLVM_YAML_IS_SEQUENCE_VECTOR(StringRef) LLVM_YAML_IS_SEQUENCE_VECTOR(DataInCode) - // for compatibility with gcc-4.7 in C++11 mode, add extra namespace namespace llvm { namespace yaml { @@ -59,6 +64,7 @@ static size_t size(IO &io, std::vector
&seq) { return seq.size(); } + static Section& element(IO &io, std::vector
&seq, size_t index) { if ( index >= seq.size() ) seq.resize(index+1); @@ -71,6 +77,7 @@ static size_t size(IO &io, std::vector &seq) { return seq.size(); } + static Symbol& element(IO &io, std::vector &seq, size_t index) { if ( index >= seq.size() ) seq.resize(index+1); @@ -84,6 +91,7 @@ static size_t size(IO &io, Relocations &seq) { return seq.size(); } + static Relocation& element(IO &io, Relocations &seq, size_t index) { if ( index >= seq.size() ) seq.resize(index+1); @@ -97,11 +105,13 @@ static size_t size(IO &io, ContentBytes &seq) { return seq.size(); } + static Hex8& element(IO &io, ContentBytes &seq, size_t index) { if ( index >= seq.size() ) seq.resize(index+1); return seq[index]; } + static const bool flow = true; }; @@ -112,11 +122,13 @@ static size_t size(IO &io, IndirectSymbols &seq) { return seq.size(); } + static uint32_t& element(IO &io, IndirectSymbols &seq, size_t index) { if ( index >= seq.size() ) seq.resize(index+1); return seq[index]; } + static const bool flow = true; }; @@ -148,7 +160,6 @@ } }; - template <> struct ScalarEnumerationTraits { static void enumeration(IO &io, HeaderFileType &value) { @@ -159,7 +170,6 @@ } }; - template <> struct ScalarBitSetTraits { static void bitset(IO &io, FileFlags &value) { @@ -170,7 +180,6 @@ } }; - template <> struct ScalarEnumerationTraits { static void enumeration(IO &io, SectionType &value) { @@ -290,10 +299,10 @@ } }; - template <> struct MappingTraits
{ struct NormalizedContentBytes; + static void mapping(IO &io, Section §) { io.mapRequired("segment", sect.segmentName); io.mapRequired("section", sect.sectionName); @@ -323,7 +332,7 @@ NormalizedContent(IO &io, ArrayRef content) : _io(io) { // When writing yaml, copy content byte array to Hex8 vector. for (auto &c : content) { - _normalizedContent.push_back(c); + _normalizedContent.emplace_back(c); } } ArrayRef denormalize(IO &io) { @@ -346,7 +355,6 @@ }; }; - template <> struct MappingTraits { static void mapping(IO &io, Relocation &reloc) { @@ -364,7 +372,6 @@ } }; - template <> struct ScalarEnumerationTraits { static void enumeration(IO &io, RelocationInfoType &value) { @@ -457,7 +464,6 @@ } }; - template <> struct MappingTraits { static void mapping(IO &io, Symbol& sym) { @@ -525,7 +531,6 @@ static bool mustQuote(StringRef) { return false; } }; - template <> struct MappingTraits { static void mapping(IO &io, Segment& seg) { @@ -586,7 +591,6 @@ } }; - template <> struct MappingTraits { static void mapping(IO &io, RebaseLocation& rebase) { @@ -597,8 +601,6 @@ } }; - - template <> struct ScalarEnumerationTraits { static void enumeration(IO &io, BindType &value) { @@ -625,7 +627,6 @@ } }; - template <> struct ScalarEnumerationTraits { static void enumeration(IO &io, ExportSymbolKind &value) { @@ -650,7 +651,6 @@ } }; - template <> struct MappingTraits { static void mapping(IO &io, Export &exp) { @@ -698,6 +698,7 @@ out << llvm::format(".%d", (value & 0xFF)); } } + static StringRef input(StringRef scalar, void*, PackedVersion &result) { uint32_t value; if (lld::MachOLinkingContext::parsePackedVersion(scalar, value)) @@ -706,6 +707,7 @@ // Return the empty string on success, return StringRef(); } + static bool mustQuote(StringRef) { return false; } }; @@ -741,6 +743,7 @@ io.mapOptional("exports", file.exportInfo); io.mapOptional("dataInCode", file.dataInCode); } + static StringRef validate(IO &io, NormalizedFile &file) { return StringRef(); } @@ -749,7 +752,6 @@ } // namespace llvm } // namespace yaml - namespace lld { namespace mach_o { @@ -794,8 +796,6 @@ return true; } - - namespace normalized { /// Parses a yaml encoded mach-o file to produce an in-memory normalized view. @@ -821,7 +821,6 @@ return std::move(f); } - /// Writes a yaml encoded mach-o files from an in-memory normalized view. std::error_code writeYaml(const NormalizedFile &file, raw_ostream &out) { // YAML I/O is not const aware, so need to cast away ;-( Index: lib/ReaderWriter/YAML/ReaderWriterYAML.cpp =================================================================== --- lib/ReaderWriter/YAML/ReaderWriterYAML.cpp +++ lib/ReaderWriter/YAML/ReaderWriterYAML.cpp @@ -557,6 +557,7 @@ static size_t size(IO &io, std::vector &seq) { return seq.size(); } + static const lld::File *&element(IO &io, std::vector &seq, size_t index) { if (index >= seq.size()) @@ -768,6 +769,7 @@ setKindValue(_mappedKind.value); return this; } + void bind(const RefNameResolver &); static StringRef targetName(IO &io, const lld::Reference *ref); @@ -826,7 +828,7 @@ ArrayRef cont = atom->rawContent(); _content.reserve(cont.size()); for (uint8_t x : cont) - _content.push_back(x); + _content.emplace_back(x); } ~NormalizedAtom() override = default; @@ -874,6 +876,7 @@ DynamicExport dynamicExport() const override { return _dynamicExport; } CodeModel codeModel() const override { return _codeModel; } ContentPermissions permissions() const override { return _permissions; } + ArrayRef rawContent() const override { if (!occupiesDiskSpace()) return ArrayRef(); @@ -888,16 +891,19 @@ const void *it = reinterpret_cast(index); return reference_iterator(*this, it); } + reference_iterator end() const override { uintptr_t index = _references.size(); const void *it = reinterpret_cast(index); return reference_iterator(*this, it); } + const lld::Reference *derefIterator(const void *it) const override { uintptr_t index = reinterpret_cast(it); assert(index < _references.size()); return _references[index]; } + void incrementIterator(const void *&it) const override { uintptr_t index = reinterpret_cast(it); ++index; @@ -1158,6 +1164,7 @@ << ", " << _name.size() << ")\n"); return this; } + // Extract current File object from YAML I/O parsing context const lld::File &fileFromContext(IO &io) { YamlContext *info = reinterpret_cast(io.getContext());