diff options
author | George Rimar <grimar@accesssoftek.com> | 2019-08-14 08:56:55 +0000 |
---|---|---|
committer | George Rimar <grimar@accesssoftek.com> | 2019-08-14 08:56:55 +0000 |
commit | 468919e18231d0c30b5c0f84a87145db06e3554b (patch) | |
tree | e1dbabaed556c88253db5a4bc75935b923ecf595 /llvm/lib/ExecutionEngine | |
parent | a0c6a3571422826e856002714d9bb008584fe8b3 (diff) | |
download | bcm5719-llvm-468919e18231d0c30b5c0f84a87145db06e3554b.tar.gz bcm5719-llvm-468919e18231d0c30b5c0f84a87145db06e3554b.zip |
Revert r368812 "[llvm/Object] - Convert SectionRef::getName() to return Expected<>"
It broke clang BB: http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/16455
llvm-svn: 368813
Diffstat (limited to 'llvm/lib/ExecutionEngine')
7 files changed, 27 insertions, 51 deletions
diff --git a/llvm/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.cpp b/llvm/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.cpp index 92c7e49039a..1501c7ad0bc 100644 --- a/llvm/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.cpp +++ b/llvm/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.cpp @@ -96,10 +96,9 @@ Error MachOAtomGraphBuilder::parseSections() { assert((SecRef.getAlignment() <= std::numeric_limits<uint32_t>::max()) && "Section alignment does not fit in 32 bits"); - Expected<StringRef> NameOrErr = SecRef.getName(); - if (!NameOrErr) - return NameOrErr.takeError(); - StringRef Name = *NameOrErr; + StringRef Name; + if (auto EC = SecRef.getName(Name)) + return errorCodeToError(EC); unsigned SectionIndex = SecRef.getIndex() + 1; diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp index 4b328624ccd..f73d1c61edf 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp @@ -535,10 +535,9 @@ Error RuntimeDyldImpl::computeTotalAllocSize(const ObjectFile &Obj, bool IsCode = Section.isText(); bool IsReadOnly = isReadOnlyData(Section); - Expected<StringRef> NameOrErr = Section.getName(); - if (!NameOrErr) - return NameOrErr.takeError(); - StringRef Name = *NameOrErr; + StringRef Name; + if (auto EC = Section.getName(Name)) + return errorCodeToError(EC); uint64_t StubBufSize = computeSectionStubBufSize(Obj, Section); @@ -778,10 +777,9 @@ RuntimeDyldImpl::emitSection(const ObjectFile &Obj, // anyway, so we should guarantee that the alignment is always at least 1. Alignment = std::max(1u, Alignment); - Expected<StringRef> NameOrErr = Section.getName(); - if (!NameOrErr) - return NameOrErr.takeError(); - StringRef Name = *NameOrErr; + StringRef Name; + if (auto EC = Section.getName(Name)) + return errorCodeToError(EC); StubBufSize = computeSectionStubBufSize(Obj, Section); diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp index e3ace265f9c..60041a45e2b 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp @@ -160,13 +160,9 @@ createRTDyldELFObject(MemoryBufferRef Buffer, const ObjectFile &SourceObject, // Iterate over all sections in the object. auto SI = SourceObject.section_begin(); for (const auto &Sec : Obj->sections()) { - Expected<StringRef> NameOrErr = Sec.getName(); - if (!NameOrErr) { - consumeError(NameOrErr.takeError()); - continue; - } - - if (*NameOrErr != "") { + StringRef SectionName; + Sec.getName(SectionName); + if (SectionName != "") { DataRefImpl ShdrRef = Sec.getRawDataRefImpl(); Elf_Shdr *shdr = const_cast<Elf_Shdr *>( reinterpret_cast<const Elf_Shdr *>(ShdrRef.p)); @@ -571,11 +567,10 @@ Error RuntimeDyldELF::findPPC64TOCSection(const ELFObjectFileBase &Obj, // The TOC consists of sections .got, .toc, .tocbss, .plt in that // order. The TOC starts where the first of these sections starts. - for (auto &Section : Obj.sections()) { - Expected<StringRef> NameOrErr = Section.getName(); - if (!NameOrErr) - return NameOrErr.takeError(); - StringRef SectionName = *NameOrErr; + for (auto &Section: Obj.sections()) { + StringRef SectionName; + if (auto EC = Section.getName(SectionName)) + return errorCodeToError(EC); if (SectionName == ".got" || SectionName == ".toc" @@ -610,10 +605,9 @@ Error RuntimeDyldELF::findOPDEntrySection(const ELFObjectFileBase &Obj, if (RelSecI == Obj.section_end()) continue; - Expected<StringRef> NameOrErr = RelSecI->getName(); - if (!NameOrErr) - return NameOrErr.takeError(); - StringRef RelSectionName = *NameOrErr; + StringRef RelSectionName; + if (auto EC = RelSecI->getName(RelSectionName)) + return errorCodeToError(EC); if (RelSectionName != ".opd") continue; @@ -1885,14 +1879,8 @@ Error RuntimeDyldELF::finalizeLoad(const ObjectFile &Obj, ObjSectionToIDMap::iterator i, e; for (i = SectionMap.begin(), e = SectionMap.end(); i != e; ++i) { const SectionRef &Section = i->first; - StringRef Name; - Expected<StringRef> NameOrErr = Section.getName(); - if (NameOrErr) - Name = *NameOrErr; - else - consumeError(NameOrErr.takeError()); - + Section.getName(Name); if (Name == ".eh_frame") { UnregisteredEHFrameSections.push_back(i->second); break; diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp index fbdfb8d5c3a..202c3ca1c50 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp @@ -233,10 +233,7 @@ RuntimeDyldMachOCRTPBase<Impl>::finalizeLoad(const ObjectFile &Obj, for (const auto &Section : Obj.sections()) { StringRef Name; - if (Expected<StringRef> NameOrErr = Section.getName()) - Name = *NameOrErr; - else - consumeError(NameOrErr.takeError()); + Section.getName(Name); // Force emission of the __text, __eh_frame, and __gcc_except_tab sections // if they're present. Otherwise call down to the impl to handle other diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h index dc4af08583d..d2d74534cf9 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h @@ -284,14 +284,14 @@ public: // Look for and record the EH frame section IDs. for (const auto &SectionPair : SectionMap) { const object::SectionRef &Section = SectionPair.first; - Expected<StringRef> NameOrErr = Section.getName(); - if (!NameOrErr) - return NameOrErr.takeError(); + StringRef Name; + if (auto EC = Section.getName(Name)) + return errorCodeToError(EC); // Note unwind info is stored in .pdata but often points to .xdata // with an IMAGE_REL_AMD64_ADDR32NB relocation. Using a memory manager // that keeps sections ordered in relation to __ImageBase is necessary. - if ((*NameOrErr) == ".pdata") + if (Name == ".pdata") UnregisteredEHFrameSections.push_back(SectionPair.second); } return Error::success(); diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h index a76958a9e2c..3bec8b979f7 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h @@ -289,10 +289,7 @@ public: Error finalizeSection(const ObjectFile &Obj, unsigned SectionID, const SectionRef &Section) { StringRef Name; - if (Expected<StringRef> NameOrErr = Section.getName()) - Name = *NameOrErr; - else - consumeError(NameOrErr.takeError()); + Section.getName(Name); if (Name == "__nl_symbol_ptr") return populateIndirectSymbolPointersSection(cast<MachOObjectFile>(Obj), diff --git a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h index 523deb29b72..f0de27ba14b 100644 --- a/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h +++ b/llvm/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h @@ -128,10 +128,7 @@ public: Error finalizeSection(const ObjectFile &Obj, unsigned SectionID, const SectionRef &Section) { StringRef Name; - if (Expected<StringRef> NameOrErr = Section.getName()) - Name = *NameOrErr; - else - consumeError(NameOrErr.takeError()); + Section.getName(Name); if (Name == "__jump_table") return populateJumpTable(cast<MachOObjectFile>(Obj), Section, SectionID); |