[llvm] r368813 - Revert r368812 "[llvm/Object] - Convert SectionRef::getName() to return Expected<>"
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 14 01:56:55 PDT 2019
Author: grimar
Date: Wed Aug 14 01:56:55 2019
New Revision: 368813
URL: http://llvm.org/viewvc/llvm-project?rev=368813&view=rev
Log:
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
Modified:
llvm/trunk/include/llvm/Object/ELFObjectFile.h
llvm/trunk/include/llvm/Object/ObjectFile.h
llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp
llvm/trunk/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.cpp
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h
llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h
llvm/trunk/lib/Object/COFFObjectFile.cpp
llvm/trunk/lib/Object/Decompressor.cpp
llvm/trunk/lib/Object/ELFObjectFile.cpp
llvm/trunk/lib/Object/MachOObjectFile.cpp
llvm/trunk/lib/Object/Object.cpp
llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp
llvm/trunk/lib/XRay/InstrumentationMap.cpp
llvm/trunk/test/Object/invalid.test
llvm/trunk/tools/dsymutil/DwarfLinker.cpp
llvm/trunk/tools/dsymutil/DwarfStreamer.cpp
llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
llvm/trunk/tools/llvm-cov/TestingSupport.cpp
llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
llvm/trunk/tools/llvm-nm/llvm-nm.cpp
llvm/trunk/tools/llvm-objdump/COFFDump.cpp
llvm/trunk/tools/llvm-objdump/MachODump.cpp
llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp
llvm/trunk/tools/llvm-pdbutil/InputFile.cpp
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
llvm/trunk/tools/llvm-readobj/MachODumper.cpp
llvm/trunk/tools/llvm-readobj/ObjDumper.cpp
llvm/trunk/tools/llvm-readobj/WasmDumper.cpp
llvm/trunk/tools/llvm-readobj/Win64EHDumper.cpp
llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp
llvm/trunk/tools/llvm-size/llvm-size.cpp
llvm/trunk/tools/obj2yaml/coff2yaml.cpp
Modified: llvm/trunk/include/llvm/Object/ELFObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELFObjectFile.h?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELFObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ELFObjectFile.h Wed Aug 14 01:56:55 2019
@@ -461,15 +461,13 @@ Expected<StringRef> ELFObjectFile<ELFT>:
if (!SymStrTabOrErr)
return SymStrTabOrErr.takeError();
Expected<StringRef> Name = ESym->getName(*SymStrTabOrErr);
- if (Name && !Name->empty())
- return Name;
// If the symbol name is empty use the section name.
- if (ESym->getType() == ELF::STT_SECTION) {
- if (Expected<section_iterator> SecOrErr = getSymbolSection(Sym)) {
- consumeError(Name.takeError());
- return (*SecOrErr)->getName();
- }
+ if ((!Name || Name->empty()) && ESym->getType() == ELF::STT_SECTION) {
+ StringRef SecName;
+ Expected<section_iterator> Sec = getSymbolSection(Sym);
+ if (Sec && !(*Sec)->getName(SecName))
+ return SecName;
}
return Name;
}
Modified: llvm/trunk/include/llvm/Object/ObjectFile.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ObjectFile.h?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ObjectFile.h (original)
+++ llvm/trunk/include/llvm/Object/ObjectFile.h Wed Aug 14 01:56:55 2019
@@ -94,7 +94,7 @@ public:
void moveNext();
- Expected<StringRef> getName() const;
+ std::error_code getName(StringRef &Result) const;
uint64_t getAddress() const;
uint64_t getIndex() const;
uint64_t getSize() const;
@@ -434,8 +434,12 @@ inline void SectionRef::moveNext() {
return OwningObject->moveSectionNext(SectionPimpl);
}
-inline Expected<StringRef> SectionRef::getName() const {
- return OwningObject->getSectionName(SectionPimpl);
+inline std::error_code SectionRef::getName(StringRef &Result) const {
+ Expected<StringRef> NameOrErr = OwningObject->getSectionName(SectionPimpl);
+ if (!NameOrErr)
+ return errorToErrorCode(NameOrErr.takeError());
+ Result = *NameOrErr;
+ return std::error_code();
}
inline uint64_t SectionRef::getAddress() const {
Modified: llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp (original)
+++ llvm/trunk/lib/DebugInfo/DWARF/DWARFContext.cpp Wed Aug 14 01:56:55 2019
@@ -1506,11 +1506,7 @@ public:
StringMap<unsigned> SectionAmountMap;
for (const SectionRef &Section : Obj.sections()) {
StringRef Name;
- if (auto NameOrErr = Section.getName())
- Name = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ Section.getName(Name);
++SectionAmountMap[Name];
SectionNames.push_back({ Name, true });
@@ -1575,15 +1571,12 @@ public:
continue;
StringRef RelSecName;
- if (auto NameOrErr = RelocatedSection->getName())
- RelSecName = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
+ StringRef RelSecData;
+ RelocatedSection->getName(RelSecName);
// If the section we're relocating was relocated already by the JIT,
// then we used the relocated version above, so we do not need to process
// relocations for it now.
- StringRef RelSecData;
if (L && L->getLoadedSectionContents(*RelocatedSection, RelSecData))
continue;
Modified: llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp (original)
+++ llvm/trunk/lib/DebugInfo/Symbolize/SymbolizableObjectFile.cpp Wed Aug 14 01:56:55 2019
@@ -54,11 +54,10 @@ SymbolizableObjectFile::create(const obj
// PowerPC64 ELF.
if (Obj->getArch() == Triple::ppc64) {
for (section_iterator Section : Obj->sections()) {
- Expected<StringRef> NameOrErr = Section->getName();
- if (!NameOrErr)
- return errorToErrorCode(NameOrErr.takeError());
-
- if (*NameOrErr == ".opd") {
+ StringRef Name;
+ if (auto EC = Section->getName(Name))
+ return EC;
+ if (Name == ".opd") {
Expected<StringRef> E = Section->getContents();
if (!E)
return errorToErrorCode(E.takeError());
Modified: llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp (original)
+++ llvm/trunk/lib/DebugInfo/Symbolize/Symbolize.cpp Wed Aug 14 01:56:55 2019
@@ -259,11 +259,7 @@ bool getGNUDebuglinkContents(const Objec
return false;
for (const SectionRef &Section : Obj->sections()) {
StringRef Name;
- if (Expected<StringRef> NameOrErr = Section.getName())
- Name = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ Section.getName(Name);
Name = Name.substr(Name.find_first_not_of("._"));
if (Name == "gnu_debuglink") {
Expected<StringRef> ContentsOrErr = Section.getContents();
Modified: llvm/trunk/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JITLink/MachOAtomGraphBuilder.cpp Wed Aug 14 01:56:55 2019
@@ -96,10 +96,9 @@ Error MachOAtomGraphBuilder::parseSectio
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;
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyld.cpp Wed Aug 14 01:56:55 2019
@@ -535,10 +535,9 @@ Error RuntimeDyldImpl::computeTotalAlloc
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 Objec
// 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);
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp Wed Aug 14 01:56:55 2019
@@ -160,13 +160,9 @@ createRTDyldELFObject(MemoryBufferRef Bu
// 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::findPPC64TOCSectio
// 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::findOPDEntrySectio
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
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;
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldMachO.cpp Wed Aug 14 01:56:55 2019
@@ -233,10 +233,7 @@ RuntimeDyldMachOCRTPBase<Impl>::finalize
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
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldCOFFX86_64.h Wed Aug 14 01:56:55 2019
@@ -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();
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOARM.h Wed Aug 14 01:56:55 2019
@@ -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),
Modified: llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h (original)
+++ llvm/trunk/lib/ExecutionEngine/RuntimeDyld/Targets/RuntimeDyldMachOI386.h Wed Aug 14 01:56:55 2019
@@ -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);
Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Wed Aug 14 01:56:55 2019
@@ -994,12 +994,11 @@ std::error_code COFFObjectFile::getSecti
std::error_code COFFObjectFile::getSection(StringRef SectionName,
const coff_section *&Result) const {
Result = nullptr;
+ StringRef SecName;
for (const SectionRef &Section : sections()) {
- auto NameOrErr = Section.getName();
- if (!NameOrErr)
- return errorToErrorCode(NameOrErr.takeError());
-
- if (*NameOrErr == SectionName) {
+ if (std::error_code E = Section.getName(SecName))
+ return E;
+ if (SecName == SectionName) {
Result = getCOFFSection(Section);
return std::error_code();
}
Modified: llvm/trunk/lib/Object/Decompressor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Decompressor.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Decompressor.cpp (original)
+++ llvm/trunk/lib/Object/Decompressor.cpp Wed Aug 14 01:56:55 2019
@@ -77,15 +77,10 @@ bool Decompressor::isGnuStyle(StringRef
}
bool Decompressor::isCompressed(const object::SectionRef &Section) {
- if (Section.isCompressed())
- return true;
-
- Expected<StringRef> SecNameOrErr = Section.getName();
- if (SecNameOrErr)
- return isGnuStyle(*SecNameOrErr);
-
- consumeError(SecNameOrErr.takeError());
- return false;
+ StringRef Name;
+ if (Section.getName(Name))
+ return false;
+ return Section.isCompressed() || isGnuStyle(Name);
}
bool Decompressor::isCompressedELFSection(uint64_t Flags, StringRef Name) {
Modified: llvm/trunk/lib/Object/ELFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/ELFObjectFile.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/Object/ELFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/ELFObjectFile.cpp Wed Aug 14 01:56:55 2019
@@ -392,13 +392,9 @@ ELFObjectFileBase::getPltAddresses() con
return {};
Optional<SectionRef> Plt = None, RelaPlt = None, GotPlt = None;
for (const SectionRef &Section : sections()) {
- Expected<StringRef> NameOrErr = Section.getName();
- if (!NameOrErr) {
- consumeError(NameOrErr.takeError());
+ StringRef Name;
+ if (Section.getName(Name))
continue;
- }
- StringRef Name = *NameOrErr;
-
if (Name == ".plt")
Plt = Section;
else if (Name == ".rela.plt" || Name == ".rel.plt")
Modified: llvm/trunk/lib/Object/MachOObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/MachOObjectFile.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/Object/MachOObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/MachOObjectFile.cpp Wed Aug 14 01:56:55 2019
@@ -1986,12 +1986,13 @@ Expected<SectionRef> MachOObjectFile::ge
}
Expected<SectionRef> MachOObjectFile::getSection(StringRef SectionName) const {
+ StringRef SecName;
for (const SectionRef &Section : sections()) {
- auto NameOrErr = Section.getName();
- if (!NameOrErr)
- return NameOrErr.takeError();
- if (*NameOrErr == SectionName)
+ if (std::error_code E = Section.getName(SecName))
+ return errorCodeToError(E);
+ if (SecName == SectionName) {
return Section;
+ }
}
return errorCodeToError(object_error::parse_failed);
}
@@ -3994,11 +3995,7 @@ BindRebaseSegInfo::BindRebaseSegInfo(con
uint64_t CurSegAddress;
for (const SectionRef &Section : Obj->sections()) {
SectionInfo Info;
- Expected<StringRef> NameOrErr = Section.getName();
- if (!NameOrErr)
- consumeError(NameOrErr.takeError());
- else
- Info.SectionName = *NameOrErr;
+ Section.getName(Info.SectionName);
Info.Address = Section.getAddress();
Info.Size = Section.getSize();
Info.SegmentName =
Modified: llvm/trunk/lib/Object/Object.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/Object.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/Object/Object.cpp (original)
+++ llvm/trunk/lib/Object/Object.cpp Wed Aug 14 01:56:55 2019
@@ -251,10 +251,10 @@ void LLVMMoveToNextSymbol(LLVMSymbolIter
// SectionRef accessors
const char *LLVMGetSectionName(LLVMSectionIteratorRef SI) {
- auto NameOrErr = (*unwrap(SI))->getName();
- if (!NameOrErr)
- report_fatal_error(NameOrErr.takeError());
- return NameOrErr->data();
+ StringRef ret;
+ if (std::error_code ec = (*unwrap(SI))->getName(ret))
+ report_fatal_error(ec.message());
+ return ret.data();
}
uint64_t LLVMGetSectionSize(LLVMSectionIteratorRef SI) {
Modified: llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp (original)
+++ llvm/trunk/lib/ProfileData/Coverage/CoverageMappingReader.cpp Wed Aug 14 01:56:55 2019
@@ -666,11 +666,11 @@ static Expected<SectionRef> lookupSectio
};
Name = stripSuffix(Name);
+ StringRef FoundName;
for (const auto &Section : OF.sections()) {
- Expected<StringRef> NameOrErr = Section.getName();
- if (!NameOrErr)
- return NameOrErr.takeError();
- if (stripSuffix(*NameOrErr) == Name)
+ if (auto EC = Section.getName(FoundName))
+ return errorCodeToError(EC);
+ if (stripSuffix(FoundName) == Name)
return Section;
}
return make_error<CoverageMapError>(coveragemap_error::no_data_found);
Modified: llvm/trunk/lib/XRay/InstrumentationMap.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/XRay/InstrumentationMap.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/lib/XRay/InstrumentationMap.cpp (original)
+++ llvm/trunk/lib/XRay/InstrumentationMap.cpp Wed Aug 14 01:56:55 2019
@@ -67,11 +67,10 @@ loadObj(StringRef Filename, object::Owni
StringRef Contents = "";
const auto &Sections = ObjFile.getBinary()->sections();
auto I = llvm::find_if(Sections, [&](object::SectionRef Section) {
- Expected<StringRef> NameOrErr = Section.getName();
- if (NameOrErr)
- return *NameOrErr == "xray_instr_map";
- consumeError(NameOrErr.takeError());
- return false;
+ StringRef Name = "";
+ if (Section.getName(Name))
+ return false;
+ return Name == "xray_instr_map";
});
if (I == Sections.end())
Modified: llvm/trunk/test/Object/invalid.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Object/invalid.test?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/test/Object/invalid.test (original)
+++ llvm/trunk/test/Object/invalid.test Wed Aug 14 01:56:55 2019
@@ -2,9 +2,9 @@
## .shstrtab has an invalid type.
# RUN: yaml2obj %s --docnum=1 -o %t1
-# RUN: not llvm-objdump -s %t1 2>&1 | FileCheck %s -DFILE=%t1 --check-prefix=INVALID-SHTYPE
+# RUN: not llvm-objdump -s %t1 2>&1 | FileCheck %s --check-prefix=INVALIDERR
-# INVALID-SHTYPE: error: '[[FILE]]': invalid sh_type for string table section [index 1]: expected SHT_STRTAB, but got SHT_PROGBITS
+# INVALIDERR: error: reading file: Invalid data was encountered while parsing the file
--- !ELF
FileHeader:
@@ -20,9 +20,7 @@ Sections:
## .shstrtab has an invalid zero-size.
# RUN: yaml2obj %s --docnum=2 -o %t2
-# RUN: not llvm-objdump -s %t2 2>&1 | FileCheck %s -DFILE=%t2 --check-prefix=STRTAB-EMPTY
-
-# STRTAB-EMPTY: error: '[[FILE]]': SHT_STRTAB string table section [index 1] is empty
+# RUN: not llvm-objdump -s %t2 2>&1 | FileCheck %s --check-prefix=INVALIDERR
--- !ELF
FileHeader:
@@ -39,9 +37,7 @@ Sections:
## size that goes past the end of the file.
# RUN: not llvm-objdump -s %p/Inputs/invalid-strtab-size.elf 2>&1 \
-# RUN: | FileCheck %s -DFILE=%p/Inputs/invalid-strtab-size.elf --check-prefix=INVALID-STRTAB-SIZE
-
-# INVALID-STRTAB-SIZE: error: '[[FILE]]': section [index 1] has a sh_offset (0x70) + sh_size (0x16777215) that cannot be represented
+# RUN: | FileCheck %s --check-prefix=INVALIDERR
## Check that llvm-dwarfdump reports an error during relocation resolution
## when instead of expected SHT_RELA section it locates a section of a different type.
@@ -76,9 +72,7 @@ Sections:
## and .shstrtab is not null-terminated.
# RUN: yaml2obj %s --docnum=4 -o %t4
-# RUN: not llvm-objdump -s %t4 2>&1 | FileCheck -DFILE=%t4 --check-prefix=SHSTRTAB-NON-TERM %s
-
-# SHSTRTAB-NON-TERM: error: '[[FILE]]': SHT_STRTAB string table section [index 1] is non-null terminated
+# RUN: not llvm-objdump -s %t4 2>&1 | FileCheck --check-prefix=INVALIDERR %s
--- !ELF
FileHeader:
Modified: llvm/trunk/tools/dsymutil/DwarfLinker.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/DwarfLinker.cpp (original)
+++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp Wed Aug 14 01:56:55 2019
@@ -538,11 +538,7 @@ bool DwarfLinker::RelocationManager::fin
// Find the debug_info section.
for (const object::SectionRef &Section : Obj.sections()) {
StringRef SectionName;
- if (Expected<StringRef> NameOrErr = Section.getName())
- SectionName = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ Section.getName(SectionName);
SectionName = SectionName.substr(SectionName.find_first_not_of("._"));
if (SectionName != "debug_info")
continue;
Modified: llvm/trunk/tools/dsymutil/DwarfStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfStreamer.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/DwarfStreamer.cpp (original)
+++ llvm/trunk/tools/dsymutil/DwarfStreamer.cpp Wed Aug 14 01:56:55 2019
@@ -31,11 +31,7 @@ static Optional<object::SectionRef>
getSectionByName(const object::ObjectFile &Obj, StringRef SecName) {
for (const object::SectionRef &Section : Obj.sections()) {
StringRef SectionName;
- if (Expected<StringRef> NameOrErr = Section.getName())
- SectionName = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ Section.getName(SectionName);
SectionName = SectionName.substr(SectionName.find_first_not_of("._"));
if (SectionName != SecName)
continue;
Modified: llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.cpp (original)
+++ llvm/trunk/tools/llvm-cfi-verify/lib/FileAnalysis.cpp Wed Aug 14 01:56:55 2019
@@ -449,10 +449,9 @@ Error FileAnalysis::parseCodeSections()
// Avoid checking the PLT since it produces spurious failures on AArch64
// when ignoring DWARF data.
- Expected<StringRef> NameOrErr = Section.getName();
- if (NameOrErr && *NameOrErr == ".plt")
+ StringRef SectionName;
+ if (!Section.getName(SectionName) && SectionName == ".plt")
continue;
- consumeError(NameOrErr.takeError());
Expected<StringRef> Contents = Section.getContents();
if (!Contents)
Modified: llvm/trunk/tools/llvm-cov/TestingSupport.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-cov/TestingSupport.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-cov/TestingSupport.cpp (original)
+++ llvm/trunk/tools/llvm-cov/TestingSupport.cpp Wed Aug 14 01:56:55 2019
@@ -50,13 +50,8 @@ int convertForTestingMain(int argc, cons
auto ObjFormat = OF->getTripleObjectFormat();
for (const auto &Section : OF->sections()) {
StringRef Name;
- if (Expected<StringRef> NameOrErr = Section.getName()) {
- Name = *NameOrErr;
- } else {
- consumeError(NameOrErr.takeError());
+ if (Section.getName(Name))
return 1;
- }
-
if (Name == llvm::getInstrProfSectionName(IPSK_name, ObjFormat,
/*AddSegmentInfo=*/false)) {
ProfileNames = Section;
Modified: llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp (original)
+++ llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp Wed Aug 14 01:56:55 2019
@@ -406,10 +406,9 @@ static Error handleSection(
if (Section.isVirtual())
return Error::success();
- Expected<StringRef> NameOrErr = Section.getName();
- if (!NameOrErr)
- return NameOrErr.takeError();
- StringRef Name = *NameOrErr;
+ StringRef Name;
+ if (std::error_code Err = Section.getName(Name))
+ return errorCodeToError(Err);
Expected<StringRef> ContentsOrErr = Section.getContents();
if (!ContentsOrErr)
Modified: llvm/trunk/tools/llvm-nm/llvm-nm.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-nm/llvm-nm.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-nm/llvm-nm.cpp (original)
+++ llvm/trunk/tools/llvm-nm/llvm-nm.cpp Wed Aug 14 01:56:55 2019
@@ -913,12 +913,10 @@ static char getSymbolNMTypeChar(ELFObjec
if (Flags & ELF::SHF_ALLOC)
return Flags & ELF::SHF_WRITE ? 'd' : 'r';
- auto NameOrErr = SecI->getName();
- if (!NameOrErr) {
- consumeError(NameOrErr.takeError());
+ StringRef SecName;
+ if (SecI->getName(SecName))
return '?';
- }
- if ((*NameOrErr).startswith(".debug"))
+ if (SecName.startswith(".debug"))
return 'N';
if (!(Flags & ELF::SHF_WRITE))
return 'n';
@@ -1092,13 +1090,8 @@ static char getNMSectionTagAndName(Symbo
consumeError(SecIOrErr.takeError());
return '?';
}
-
- Expected<StringRef> NameOrErr = (*SecIOrErr)->getName();
- if (!NameOrErr) {
- consumeError(SecIOrErr.takeError());
- return '?';
- }
- SecName = *NameOrErr;
+ elf_section_iterator secT = *SecIOrErr;
+ secT->getName(SecName);
}
}
@@ -1354,12 +1347,7 @@ dumpSymbolNamesFromObject(SymbolicFile &
StringRef SectionName = StringRef();
for (const SectionRef &Section : MachO->sections()) {
S.NSect++;
-
- if (Expected<StringRef> NameOrErr = Section.getName())
- SectionName = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ Section.getName(SectionName);
SegmentName = MachO->getSectionFinalSegmentName(
Section.getRawDataRefImpl());
if (S.Address >= Section.getAddress() &&
@@ -1679,11 +1667,7 @@ dumpSymbolNamesFromObject(SymbolicFile &
StringRef SegmentName = StringRef();
StringRef SectionName = StringRef();
for (const SectionRef &Section : MachO->sections()) {
- if (Expected<StringRef> NameOrErr = Section.getName())
- SectionName = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ Section.getName(SectionName);
SegmentName = MachO->getSectionFinalSegmentName(
Section.getRawDataRefImpl());
F.NSect++;
Modified: llvm/trunk/tools/llvm-objdump/COFFDump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/COFFDump.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/COFFDump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/COFFDump.cpp Wed Aug 14 01:56:55 2019
@@ -442,7 +442,8 @@ static bool getPDataSection(const COFFOb
std::vector<RelocationRef> &Rels,
const RuntimeFunction *&RFStart, int &NumRFs) {
for (const SectionRef &Section : Obj->sections()) {
- StringRef Name = unwrapOrError(Section.getName(), Obj->getFileName());
+ StringRef Name;
+ error(Section.getName(Name));
if (Name != ".pdata")
continue;
Modified: llvm/trunk/tools/llvm-objdump/MachODump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/MachODump.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/MachODump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/MachODump.cpp Wed Aug 14 01:56:55 2019
@@ -371,8 +371,11 @@ static void getSectionsAndSymbols(MachOO
Symbols.push_back(Symbol);
}
- for (const SectionRef &Section : MachOObj->sections())
+ for (const SectionRef &Section : MachOObj->sections()) {
+ StringRef SectName;
+ Section.getName(SectName);
Sections.push_back(Section);
+ }
bool BaseSegmentAddressSet = false;
for (const auto &Command : MachOObj->load_commands()) {
@@ -446,11 +449,13 @@ static void printRelocationTargetName(co
// If we couldn't find a symbol that this relocation refers to, try
// to find a section beginning instead.
for (const SectionRef &Section : ToolSectionFilter(*O)) {
+ StringRef Name;
uint64_t Addr = Section.getAddress();
if (Addr != Val)
continue;
- StringRef NameOrErr = unwrapOrError(Section.getName(), O->getFileName());
- Fmt << NameOrErr;
+ if (std::error_code EC = Section.getName(Name))
+ report_error(errorCodeToError(EC), O->getFileName());
+ Fmt << Name;
return;
}
@@ -483,14 +488,10 @@ static void printRelocationTargetName(co
--I;
advance(SI, 1);
}
- if (SI == O->section_end()) {
+ if (SI == O->section_end())
Fmt << Val << " (?,?)";
- } else {
- if (Expected<StringRef> NameOrErr = SI->getName())
- S = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
- }
+ else
+ SI->getName(S);
}
Fmt << S;
@@ -1530,12 +1531,7 @@ static void DumpLiteralPointerSection(Ma
uint64_t SectSize = Sect->getSize();
StringRef SectName;
- Expected<StringRef> SectNameOrErr = Sect->getName();
- if (SectNameOrErr)
- SectName = *SectNameOrErr;
- else
- consumeError(SectNameOrErr.takeError());
-
+ Sect->getName(SectName);
DataRefImpl Ref = Sect->getRawDataRefImpl();
StringRef SegmentName = O->getSectionFinalSegmentName(Ref);
outs() << SegmentName << ":" << SectName << ":";
@@ -1747,12 +1743,7 @@ static void DumpSectionContents(StringRe
}
for (const SectionRef &Section : O->sections()) {
StringRef SectName;
- Expected<StringRef> SecNameOrErr = Section.getName();
- if (SecNameOrErr)
- SectName = *SecNameOrErr;
- else
- consumeError(SecNameOrErr.takeError());
-
+ Section.getName(SectName);
DataRefImpl Ref = Section.getRawDataRefImpl();
StringRef SegName = O->getSectionFinalSegmentName(Ref);
if ((DumpSegName.empty() || SegName == DumpSegName) &&
@@ -1848,12 +1839,7 @@ static void DumpInfoPlistSectionContents
MachOObjectFile *O) {
for (const SectionRef &Section : O->sections()) {
StringRef SectName;
- Expected<StringRef> SecNameOrErr = Section.getName();
- if (SecNameOrErr)
- SectName = *SecNameOrErr;
- else
- consumeError(SecNameOrErr.takeError());
-
+ Section.getName(SectName);
DataRefImpl Ref = Section.getRawDataRefImpl();
StringRef SegName = O->getSectionFinalSegmentName(Ref);
if (SegName == "__TEXT" && SectName == "__info_plist") {
@@ -1950,11 +1936,7 @@ static void ProcessMachO(StringRef Name,
if (DisassembleAll) {
for (const SectionRef &Section : MachOOF->sections()) {
StringRef SectName;
- if (Expected<StringRef> NameOrErr = Section.getName())
- SectName = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ Section.getName(SectName);
if (SectName.equals("__text")) {
DataRefImpl Ref = Section.getRawDataRefImpl();
StringRef SegName = MachOOF->getSectionFinalSegmentName(Ref);
@@ -3265,13 +3247,7 @@ static const char *get_pointer_64(uint64
continue;
if (objc_only) {
StringRef SectName;
- Expected<StringRef> SecNameOrErr =
- ((*(info->Sections))[SectIdx]).getName();
- if (SecNameOrErr)
- SectName = *SecNameOrErr;
- else
- consumeError(SecNameOrErr.takeError());
-
+ ((*(info->Sections))[SectIdx]).getName(SectName);
DataRefImpl Ref = ((*(info->Sections))[SectIdx]).getRawDataRefImpl();
StringRef SegName = info->O->getSectionFinalSegmentName(Ref);
if (SegName != "__OBJC" && SectName != "__cstring")
@@ -4063,12 +4039,7 @@ static const SectionRef get_section(Mach
const char *sectname) {
for (const SectionRef &Section : O->sections()) {
StringRef SectName;
- Expected<StringRef> SecNameOrErr = Section.getName();
- if (SecNameOrErr)
- SectName = *SecNameOrErr;
- else
- consumeError(SecNameOrErr.takeError());
-
+ Section.getName(SectName);
DataRefImpl Ref = Section.getRawDataRefImpl();
StringRef SegName = O->getSectionFinalSegmentName(Ref);
if (SegName == segname && SectName == sectname)
@@ -4085,12 +4056,7 @@ walk_pointer_list_64(const char *listnam
return;
StringRef SectName;
- Expected<StringRef> SecNameOrErr = S.getName();
- if (SecNameOrErr)
- SectName = *SecNameOrErr;
- else
- consumeError(SecNameOrErr.takeError());
-
+ S.getName(SectName);
DataRefImpl Ref = S.getRawDataRefImpl();
StringRef SegName = O->getSectionFinalSegmentName(Ref);
outs() << "Contents of (" << SegName << "," << SectName << ") section\n";
@@ -4139,7 +4105,8 @@ walk_pointer_list_32(const char *listnam
if (S == SectionRef())
return;
- StringRef SectName = unwrapOrError(S.getName(), O->getFileName());
+ StringRef SectName;
+ S.getName(SectName);
DataRefImpl Ref = S.getRawDataRefImpl();
StringRef SegName = O->getSectionFinalSegmentName(Ref);
outs() << "Contents of (" << SegName << "," << SectName << ") section\n";
@@ -5813,12 +5780,7 @@ static void print_message_refs64(Section
return;
StringRef SectName;
- Expected<StringRef> SecNameOrErr = S.getName();
- if (SecNameOrErr)
- SectName = *SecNameOrErr;
- else
- consumeError(SecNameOrErr.takeError());
-
+ S.getName(SectName);
DataRefImpl Ref = S.getRawDataRefImpl();
StringRef SegName = info->O->getSectionFinalSegmentName(Ref);
outs() << "Contents of (" << SegName << "," << SectName << ") section\n";
@@ -5881,12 +5843,7 @@ static void print_message_refs32(Section
return;
StringRef SectName;
- Expected<StringRef> SecNameOrErr = S.getName();
- if (SecNameOrErr)
- SectName = *SecNameOrErr;
- else
- consumeError(SecNameOrErr.takeError());
-
+ S.getName(SectName);
DataRefImpl Ref = S.getRawDataRefImpl();
StringRef SegName = info->O->getSectionFinalSegmentName(Ref);
outs() << "Contents of (" << SegName << "," << SectName << ") section\n";
@@ -5932,12 +5889,7 @@ static void print_image_info64(SectionRe
return;
StringRef SectName;
- Expected<StringRef> SecNameOrErr = S.getName();
- if (SecNameOrErr)
- SectName = *SecNameOrErr;
- else
- consumeError(SecNameOrErr.takeError());
-
+ S.getName(SectName);
DataRefImpl Ref = S.getRawDataRefImpl();
StringRef SegName = info->O->getSectionFinalSegmentName(Ref);
outs() << "Contents of (" << SegName << "," << SectName << ") section\n";
@@ -5994,12 +5946,7 @@ static void print_image_info32(SectionRe
return;
StringRef SectName;
- Expected<StringRef> SecNameOrErr = S.getName();
- if (SecNameOrErr)
- SectName = *SecNameOrErr;
- else
- consumeError(SecNameOrErr.takeError());
-
+ S.getName(SectName);
DataRefImpl Ref = S.getRawDataRefImpl();
StringRef SegName = info->O->getSectionFinalSegmentName(Ref);
outs() << "Contents of (" << SegName << "," << SectName << ") section\n";
@@ -6049,12 +5996,7 @@ static void print_image_info(SectionRef
const char *r;
StringRef SectName;
- Expected<StringRef> SecNameOrErr = S.getName();
- if (SecNameOrErr)
- SectName = *SecNameOrErr;
- else
- consumeError(SecNameOrErr.takeError());
-
+ S.getName(SectName);
DataRefImpl Ref = S.getRawDataRefImpl();
StringRef SegName = info->O->getSectionFinalSegmentName(Ref);
outs() << "Contents of (" << SegName << "," << SectName << ") section\n";
@@ -6089,8 +6031,11 @@ static void printObjc2_64bit_MetaData(Ma
CreateSymbolAddressMap(O, &AddrMap);
std::vector<SectionRef> Sections;
- for (const SectionRef &Section : O->sections())
+ for (const SectionRef &Section : O->sections()) {
+ StringRef SectName;
+ Section.getName(SectName);
Sections.push_back(Section);
+ }
struct DisassembleInfo info(O, &AddrMap, &Sections, verbose);
@@ -6171,8 +6116,11 @@ static void printObjc2_32bit_MetaData(Ma
CreateSymbolAddressMap(O, &AddrMap);
std::vector<SectionRef> Sections;
- for (const SectionRef &Section : O->sections())
+ for (const SectionRef &Section : O->sections()) {
+ StringRef SectName;
+ Section.getName(SectName);
Sections.push_back(Section);
+ }
struct DisassembleInfo info(O, &AddrMap, &Sections, verbose);
@@ -6266,8 +6214,11 @@ static bool printObjc1_32bit_MetaData(Ma
CreateSymbolAddressMap(O, &AddrMap);
std::vector<SectionRef> Sections;
- for (const SectionRef &Section : O->sections())
+ for (const SectionRef &Section : O->sections()) {
+ StringRef SectName;
+ Section.getName(SectName);
Sections.push_back(Section);
+ }
struct DisassembleInfo info(O, &AddrMap, &Sections, verbose);
@@ -6424,8 +6375,11 @@ static void DumpProtocolSection(MachOObj
CreateSymbolAddressMap(O, &AddrMap);
std::vector<SectionRef> Sections;
- for (const SectionRef &Section : O->sections())
+ for (const SectionRef &Section : O->sections()) {
+ StringRef SectName;
+ Section.getName(SectName);
Sections.push_back(Section);
+ }
struct DisassembleInfo info(O, &AddrMap, &Sections, true);
@@ -7390,12 +7344,8 @@ static void DisassembleMachO(StringRef F
outs() << "(" << DisSegName << "," << DisSectName << ") section\n";
for (unsigned SectIdx = 0; SectIdx != Sections.size(); SectIdx++) {
- Expected<StringRef> SecNameOrErr = Sections[SectIdx].getName();
- if (!SecNameOrErr) {
- consumeError(SecNameOrErr.takeError());
- continue;
- }
- if (*SecNameOrErr != DisSectName)
+ StringRef SectName;
+ if (Sections[SectIdx].getName(SectName) || SectName != DisSectName)
continue;
DataRefImpl DR = Sections[SectIdx].getRawDataRefImpl();
@@ -7792,12 +7742,8 @@ static void findUnwindRelocNameAddend(co
auto Sym = Symbols.upper_bound(Addr);
if (Sym == Symbols.begin()) {
// The first symbol in the object is after this reference, the best we can
- // do is section-relative notation.
- if (Expected<StringRef> NameOrErr = RelocSection.getName())
- Name = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ // do is section-relative notation.
+ RelocSection.getName(Name);
Addend = Addr - SectionAddr;
return;
}
@@ -7816,11 +7762,7 @@ static void findUnwindRelocNameAddend(co
// There is a symbol before this reference, but it's in a different
// section. Probably not helpful to mention it, so use the section name.
- if (Expected<StringRef> NameOrErr = RelocSection.getName())
- Name = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ RelocSection.getName(Name);
Addend = Addr - SectionAddr;
}
@@ -8185,11 +8127,7 @@ void printMachOUnwindInfo(const MachOObj
for (const SectionRef &Section : Obj->sections()) {
StringRef SectName;
- if (Expected<StringRef> NameOrErr = Section.getName())
- SectName = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ Section.getName(SectName);
if (SectName == "__compact_unwind")
printMachOCompactUnwindSection(Obj, Symbols, Section);
else if (SectName == "__unwind_info")
Modified: llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp (original)
+++ llvm/trunk/tools/llvm-objdump/llvm-objdump.cpp Wed Aug 14 01:56:55 2019
@@ -344,14 +344,10 @@ typedef std::vector<std::tuple<uint64_t,
static bool shouldKeep(object::SectionRef S) {
if (FilterSections.empty())
return true;
-
- Expected<StringRef> SecNameOrErr = S.getName();
- if (!SecNameOrErr) {
- consumeError(SecNameOrErr.takeError());
+ StringRef SecName;
+ std::error_code error = S.getName(SecName);
+ if (error)
return false;
- }
- StringRef SecName = *SecNameOrErr;
-
// StringSet does not allow empty key so avoid adding sections with
// no name (such as the section with index 0) here.
if (!SecName.empty())
@@ -924,12 +920,10 @@ static void addPltEntries(const ObjectFi
StringSaver &Saver) {
Optional<SectionRef> Plt = None;
for (const SectionRef &Section : Obj->sections()) {
- Expected<StringRef> SecNameOrErr = Section.getName();
- if (!SecNameOrErr) {
- consumeError(SecNameOrErr.takeError());
+ StringRef Name;
+ if (Section.getName(Name))
continue;
- }
- if (*SecNameOrErr == ".plt")
+ if (Name == ".plt")
Plt = Section;
}
if (!Plt)
@@ -1212,8 +1206,9 @@ static void disassembleObject(const Targ
DataRefImpl DR = Section.getRawDataRefImpl();
SegmentName = MachO->getSectionFinalSegmentName(DR);
}
+ StringRef SectionName;
+ error(Section.getName(SectionName));
- StringRef SectionName = unwrapOrError(Section.getName(), Obj->getFileName());
// If the section has no symbol at the start, just insert a dummy one.
if (Symbols.empty() || std::get<0>(Symbols[0]) != 0) {
Symbols.insert(
@@ -1586,7 +1581,8 @@ void printRelocations(const ObjectFile *
}
for (std::pair<SectionRef, std::vector<SectionRef>> &P : SecToRelSec) {
- StringRef SecName = unwrapOrError(P.first.getName(), Obj->getFileName());
+ StringRef SecName;
+ error(P.first.getName(SecName));
outs() << "RELOCATION RECORDS FOR [" << SecName << "]:\n";
for (SectionRef Section : P.second) {
@@ -1658,7 +1654,8 @@ void printSectionHeaders(const ObjectFil
"Idx Name Size VMA Type\n";
for (const SectionRef &Section : ToolSectionFilter(*Obj)) {
- StringRef Name = unwrapOrError(Section.getName(), Obj->getFileName());
+ StringRef Name;
+ error(Section.getName(Name));
uint64_t VMA = Section.getAddress();
if (shouldAdjustVA(Section))
VMA += AdjustVMA;
@@ -1685,7 +1682,8 @@ void printSectionHeaders(const ObjectFil
void printSectionContents(const ObjectFile *Obj) {
for (const SectionRef &Section : ToolSectionFilter(*Obj)) {
- StringRef Name = unwrapOrError(Section.getName(), Obj->getFileName());
+ StringRef Name;
+ error(Section.getName(Name));
uint64_t BaseAddr = Section.getAddress();
uint64_t Size = Section.getSize();
if (!Size)
@@ -1749,16 +1747,11 @@ void printSymbolTable(const ObjectFile *
section_iterator Section = unwrapOrError(Symbol.getSection(), ArchiveName,
FileName, ArchitectureName);
StringRef Name;
- if (Type == SymbolRef::ST_Debug && Section != O->section_end()) {
- if (Expected<StringRef> NameOrErr = Section->getName())
- Name = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
- } else {
+ if (Type == SymbolRef::ST_Debug && Section != O->section_end())
+ Section->getName(Name);
+ else
Name = unwrapOrError(Symbol.getName(), ArchiveName, FileName,
ArchitectureName);
- }
bool Global = Flags & SymbolRef::SF_Global;
bool Weak = Flags & SymbolRef::SF_Weak;
@@ -1804,8 +1797,8 @@ void printSymbolTable(const ObjectFile *
StringRef SegmentName = MachO->getSectionFinalSegmentName(DR);
outs() << SegmentName << ",";
}
- StringRef SectionName =
- unwrapOrError(Section->getName(), O->getFileName());
+ StringRef SectionName;
+ error(Section->getName(SectionName));
outs() << SectionName;
}
@@ -1878,11 +1871,7 @@ void printRawClangAST(const ObjectFile *
Optional<object::SectionRef> ClangASTSection;
for (auto Sec : ToolSectionFilter(*Obj)) {
StringRef Name;
- if (Expected<StringRef> NameOrErr = Sec.getName())
- Name = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ Sec.getName(Name);
if (Name == ClangASTSectionName) {
ClangASTSection = Sec;
break;
@@ -1914,11 +1903,7 @@ static void printFaultMaps(const ObjectF
for (auto Sec : ToolSectionFilter(*Obj)) {
StringRef Name;
- if (Expected<StringRef> NameOrErr = Sec.getName())
- Name = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ Sec.getName(Name);
if (Name == FaultMapSectionName) {
FaultMapSection = Sec;
break;
Modified: llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/DumpOutputStyle.cpp Wed Aug 14 01:56:55 2019
@@ -1369,10 +1369,9 @@ Error DumpOutputStyle::dumpTypesFromObje
LazyRandomTypeCollection Types(100);
for (const auto &S : getObj().sections()) {
- Expected<StringRef> NameOrErr = S.getName();
- if (!NameOrErr)
- return NameOrErr.takeError();
- StringRef SectionName = *NameOrErr;
+ StringRef SectionName;
+ if (auto EC = S.getName(SectionName))
+ return errorCodeToError(EC);
// .debug$T is a standard CodeView type section, while .debug$P is the same
// format but used for MSVC precompiled header object files.
Modified: llvm/trunk/tools/llvm-pdbutil/InputFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-pdbutil/InputFile.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-pdbutil/InputFile.cpp (original)
+++ llvm/trunk/tools/llvm-pdbutil/InputFile.cpp Wed Aug 14 01:56:55 2019
@@ -66,13 +66,12 @@ getModuleDebugStream(PDBFile &File, Stri
static inline bool isCodeViewDebugSubsection(object::SectionRef Section,
StringRef Name,
BinaryStreamReader &Reader) {
- if (Expected<StringRef> NameOrErr = Section.getName()) {
- if (*NameOrErr != Name)
- return false;
- } else {
- consumeError(NameOrErr.takeError());
+ StringRef SectionName;
+ if (Section.getName(SectionName))
+ return false;
+
+ if (SectionName != Name)
return false;
- }
Expected<StringRef> ContentsOrErr = Section.getContents();
if (!ContentsOrErr) {
Modified: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/COFFDumper.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp Wed Aug 14 01:56:55 2019
@@ -891,14 +891,16 @@ void COFFDumper::printBaseOfDataField(co
void COFFDumper::printCodeViewDebugInfo() {
// Print types first to build CVUDTNames, then print symbols.
for (const SectionRef &S : Obj->sections()) {
- StringRef SectionName = unwrapOrError(Obj->getFileName(), S.getName());
+ StringRef SectionName;
+ error(S.getName(SectionName));
// .debug$T is a standard CodeView type section, while .debug$P is the same
// format but used for MSVC precompiled header object files.
if (SectionName == ".debug$T" || SectionName == ".debug$P")
printCodeViewTypeSection(SectionName, S);
}
for (const SectionRef &S : Obj->sections()) {
- StringRef SectionName = unwrapOrError(Obj->getFileName(), S.getName());
+ StringRef SectionName;
+ error(S.getName(SectionName));
if (SectionName == ".debug$S")
printCodeViewSymbolSection(SectionName, S);
}
@@ -1240,7 +1242,8 @@ void COFFDumper::mergeCodeViewTypes(Merg
GlobalTypeTableBuilder &GlobalCVTypes,
bool GHash) {
for (const SectionRef &S : Obj->sections()) {
- StringRef SectionName = unwrapOrError(Obj->getFileName(), S.getName());
+ StringRef SectionName;
+ error(S.getName(SectionName));
if (SectionName == ".debug$T") {
StringRef Data = unwrapOrError(Obj->getFileName(), S.getContents());
uint32_t Magic;
@@ -1308,7 +1311,8 @@ void COFFDumper::printSectionHeaders() {
++SectionNumber;
const coff_section *Section = Obj->getCOFFSection(Sec);
- StringRef Name = unwrapOrError(Obj->getFileName(), Sec.getName());
+ StringRef Name;
+ error(Sec.getName(Name));
DictScope D(W, "Section");
W.printNumber("Number", SectionNumber);
@@ -1355,7 +1359,8 @@ void COFFDumper::printRelocations() {
int SectionNumber = 0;
for (const SectionRef &Section : Obj->sections()) {
++SectionNumber;
- StringRef Name = unwrapOrError(Obj->getFileName(), Section.getName());
+ StringRef Name;
+ error(Section.getName(Name));
bool PrintedGroup = false;
for (const RelocationRef &Reloc : Section.relocations()) {
@@ -1684,7 +1689,9 @@ void COFFDumper::printCOFFExports() {
void COFFDumper::printCOFFDirectives() {
for (const SectionRef &Section : Obj->sections()) {
- StringRef Name = unwrapOrError(Obj->getFileName(), Section.getName());
+ StringRef Name;
+
+ error(Section.getName(Name));
if (Name != ".drectve")
continue;
@@ -1723,7 +1730,8 @@ void COFFDumper::printCOFFBaseReloc() {
void COFFDumper::printCOFFResources() {
ListScope ResourcesD(W, "Resources");
for (const SectionRef &S : Obj->sections()) {
- StringRef Name = unwrapOrError(Obj->getFileName(), S.getName());
+ StringRef Name;
+ error(S.getName(Name));
if (!Name.startswith(".rsrc"))
continue;
@@ -1847,11 +1855,7 @@ void COFFDumper::printStackMap() const {
object::SectionRef StackMapSection;
for (auto Sec : Obj->sections()) {
StringRef Name;
- if (Expected<StringRef> NameOrErr = Sec.getName())
- Name = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ Sec.getName(Name);
if (Name == ".llvm_stackmaps") {
StackMapSection = Sec;
break;
@@ -1878,11 +1882,7 @@ void COFFDumper::printAddrsig() {
object::SectionRef AddrsigSection;
for (auto Sec : Obj->sections()) {
StringRef Name;
- if (Expected<StringRef> NameOrErr = Sec.getName())
- Name = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ Sec.getName(Name);
if (Name == ".llvm_addrsig") {
AddrsigSection = Sec;
break;
Modified: llvm/trunk/tools/llvm-readobj/ELFDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ELFDumper.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ELFDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ELFDumper.cpp Wed Aug 14 01:56:55 2019
@@ -4669,11 +4669,7 @@ void DumpStyle<ELFT>::printNonRelocatabl
StringRef FileStr = Obj->getFileName();
for (const SectionRef &Sec : Obj->sections()) {
StringRef SectionName;
- if (Expected<StringRef> NameOrErr = Sec.getName())
- SectionName = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ Sec.getName(SectionName);
const Elf_Shdr *ElfSec = Obj->getSection(Sec.getRawDataRefImpl());
if (!SectionName.startswith(".stack_sizes"))
continue;
@@ -4721,11 +4717,7 @@ void DumpStyle<ELFT>::printRelocatableSt
for (const SectionRef &Sec : Obj->sections()) {
StringRef SectionName;
- if (Expected<StringRef> NameOrErr = Sec.getName())
- SectionName = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ Sec.getName(SectionName);
// A stack size section that we haven't encountered yet is mapped to the
// null section until we find its corresponding relocation section.
if (SectionName.startswith(".stack_sizes"))
@@ -4762,11 +4754,7 @@ void DumpStyle<ELFT>::printRelocatableSt
// Warn about stack size sections without a relocation section.
StringRef StackSizeSectionName;
- if (Expected<StringRef> NameOrErr = StackSizesSec.getName())
- StackSizeSectionName = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ StackSizesSec.getName(StackSizeSectionName);
if (RelocSec == NullSection) {
reportWarning(" '" + FileStr + "': section " + StackSizeSectionName +
" does not have a corresponding "
@@ -4794,12 +4782,7 @@ void DumpStyle<ELFT>::printRelocatableSt
for (const RelocationRef &Reloc : RelocSec.relocations()) {
if (!IsSupportedFn(Reloc.getType())) {
StringRef RelocSectionName;
- Expected<StringRef> NameOrErr = RelocSec.getName();
- if (NameOrErr)
- RelocSectionName = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ RelocSec.getName(RelocSectionName);
StringRef RelocName = EF->getRelocationTypeName(Reloc.getType());
reportError(
createStringError(object_error::parse_failed,
Modified: llvm/trunk/tools/llvm-readobj/MachODumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/MachODumper.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/MachODumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/MachODumper.cpp Wed Aug 14 01:56:55 2019
@@ -440,7 +440,10 @@ void MachODumper::printSectionHeaders(co
MachOSection MOSection;
getSection(Obj, Section.getRawDataRefImpl(), MOSection);
DataRefImpl DR = Section.getRawDataRefImpl();
- StringRef Name = unwrapOrError(Obj->getFileName(), Section.getName());
+
+ StringRef Name;
+ error(Section.getName(Name));
+
ArrayRef<char> RawName = Obj->getSectionRawName(DR);
StringRef SegmentName = Obj->getSectionFinalSegmentName(DR);
ArrayRef<char> RawSegmentName = Obj->getSectionRawFinalSegmentName(DR);
@@ -491,7 +494,9 @@ void MachODumper::printRelocations() {
std::error_code EC;
for (const SectionRef &Section : Obj->sections()) {
- StringRef Name = unwrapOrError(Obj->getFileName(), Section.getName());
+ StringRef Name;
+ error(Section.getName(Name));
+
bool PrintedGroup = false;
for (const RelocationRef &Reloc : Section.relocations()) {
if (!PrintedGroup) {
@@ -536,8 +541,9 @@ void MachODumper::printRelocation(const
}
} else if (!IsScattered) {
section_iterator SecI = Obj->getRelocationSection(DR);
- if (SecI != Obj->section_end())
- TargetName = unwrapOrError(Obj->getFileName(), SecI->getName());
+ if (SecI != Obj->section_end()) {
+ error(SecI->getName(TargetName));
+ }
}
if (TargetName.empty())
TargetName = "-";
@@ -608,7 +614,7 @@ void MachODumper::printSymbol(const Symb
error(errorToErrorCode(SecIOrErr.takeError()));
section_iterator SecI = *SecIOrErr;
if (SecI != Obj->section_end())
- SectionName = unwrapOrError(Obj->getFileName(), SecI->getName());
+ error(SecI->getName(SectionName));
DictScope D(W, "Symbol");
W.printNumber("Name", SymbolName, MOSymbol.StringIndex);
@@ -638,11 +644,7 @@ void MachODumper::printStackMap() const
object::SectionRef StackMapSection;
for (auto Sec : Obj->sections()) {
StringRef Name;
- if (Expected<StringRef> NameOrErr = Sec.getName())
- Name = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ Sec.getName(Name);
if (Name == "__llvm_stackmaps") {
StackMapSection = Sec;
break;
Modified: llvm/trunk/tools/llvm-readobj/ObjDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ObjDumper.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/ObjDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/ObjDumper.cpp Wed Aug 14 01:56:55 2019
@@ -49,7 +49,8 @@ getSectionRefsByNameOrIndex(const object
SecIndex = Obj->isELF() ? 0 : 1;
for (object::SectionRef SecRef : Obj->sections()) {
- StringRef SecName = unwrapOrError(Obj->getFileName(), SecRef.getName());
+ StringRef SecName;
+ error(SecRef.getName(SecName));
auto NameIt = SecNames.find(SecName);
if (NameIt != SecNames.end())
NameIt->second = true;
@@ -76,9 +77,8 @@ void ObjDumper::printSectionsAsString(co
bool First = true;
for (object::SectionRef Section :
getSectionRefsByNameOrIndex(Obj, Sections)) {
- StringRef SectionName =
- unwrapOrError(Obj->getFileName(), Section.getName());
-
+ StringRef SectionName;
+ error(Section.getName(SectionName));
if (!First)
W.startLine() << '\n';
First = false;
@@ -111,9 +111,8 @@ void ObjDumper::printSectionsAsHex(const
bool First = true;
for (object::SectionRef Section :
getSectionRefsByNameOrIndex(Obj, Sections)) {
- StringRef SectionName =
- unwrapOrError(Obj->getFileName(), Section.getName());
-
+ StringRef SectionName;
+ error(Section.getName(SectionName));
if (!First)
W.startLine() << '\n';
First = false;
Modified: llvm/trunk/tools/llvm-readobj/WasmDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/WasmDumper.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/WasmDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/WasmDumper.cpp Wed Aug 14 01:56:55 2019
@@ -133,8 +133,8 @@ void WasmDumper::printRelocations() {
int SectionNumber = 0;
for (const SectionRef &Section : Obj->sections()) {
bool PrintedGroup = false;
- StringRef Name = unwrapOrError(Obj->getFileName(), Section.getName());
-
+ StringRef Name;
+ error(Section.getName(Name));
++SectionNumber;
for (const RelocationRef &Reloc : Section.relocations()) {
Modified: llvm/trunk/tools/llvm-readobj/Win64EHDumper.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/Win64EHDumper.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-readobj/Win64EHDumper.cpp (original)
+++ llvm/trunk/tools/llvm-readobj/Win64EHDumper.cpp Wed Aug 14 01:56:55 2019
@@ -306,10 +306,7 @@ void Dumper::printRuntimeFunction(const
void Dumper::printData(const Context &Ctx) {
for (const auto &Section : Ctx.COFF.sections()) {
StringRef Name;
- if (Expected<StringRef> NameOrErr = Section.getName())
- Name = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
+ Section.getName(Name);
if (Name != ".pdata" && !Name.startswith(".pdata$"))
continue;
Modified: llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp (original)
+++ llvm/trunk/tools/llvm-rtdyld/llvm-rtdyld.cpp Wed Aug 14 01:56:55 2019
@@ -441,6 +441,8 @@ static int printLineInfoForInput(bool Lo
continue;
}
object::section_iterator Sec = *SecOrErr;
+ StringRef SecName;
+ Sec->getName(SecName);
Address.SectionIndex = Sec->getIndex();
uint64_t SectionLoadAddress =
LoadedObjInfo->getSectionLoadAddress(*Sec);
Modified: llvm/trunk/tools/llvm-size/llvm-size.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-size/llvm-size.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-size/llvm-size.cpp (original)
+++ llvm/trunk/tools/llvm-size/llvm-size.cpp Wed Aug 14 01:56:55 2019
@@ -106,6 +106,17 @@ static bool HadError = false;
static std::string ToolName;
+/// If ec is not success, print the error and return true.
+static bool error(std::error_code ec) {
+ if (!ec)
+ return false;
+
+ HadError = true;
+ errs() << ToolName << ": error reading file: " << ec.message() << ".\n";
+ errs().flush();
+ return true;
+}
+
static bool error(Twine Message) {
HadError = true;
errs() << ToolName << ": " << Message << ".\n";
@@ -386,14 +397,11 @@ static void printObjectSectionSizes(Obje
uint64_t size = Section.getSize();
total += size;
- Expected<StringRef> name_or_err = Section.getName();
- if (!name_or_err) {
- error(name_or_err.takeError(), Obj->getFileName());
+ StringRef name;
+ if (error(Section.getName(name)))
return;
- }
-
uint64_t addr = Section.getAddress();
- max_name_len = std::max(max_name_len, name_or_err->size());
+ max_name_len = std::max(max_name_len, name.size());
max_size_len = std::max(max_size_len, getNumLengthAsString(size));
max_addr_len = std::max(max_addr_len, getNumLengthAsString(addr));
}
@@ -423,16 +431,14 @@ static void printObjectSectionSizes(Obje
for (const SectionRef &Section : Obj->sections()) {
if (!considerForSize(Obj, Section))
continue;
-
- Expected<StringRef> name_or_err = Section.getName();
- if (!name_or_err) {
- error(name_or_err.takeError(), Obj->getFileName());
+ StringRef name;
+ if (error(Section.getName(name)))
return;
- }
-
uint64_t size = Section.getSize();
uint64_t addr = Section.getAddress();
- outs() << format(fmt.str().c_str(), name_or_err->str().c_str(), size, addr);
+ std::string namestr = name;
+
+ outs() << format(fmt.str().c_str(), namestr.c_str(), size, addr);
}
if (ELFCommons) {
Modified: llvm/trunk/tools/obj2yaml/coff2yaml.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/obj2yaml/coff2yaml.cpp?rev=368813&r1=368812&r2=368813&view=diff
==============================================================================
--- llvm/trunk/tools/obj2yaml/coff2yaml.cpp (original)
+++ llvm/trunk/tools/obj2yaml/coff2yaml.cpp Wed Aug 14 01:56:55 2019
@@ -112,14 +112,10 @@ initializeFileAndStringTable(const llvm:
if (SC.hasStrings() && SC.hasChecksums())
break;
- Expected<StringRef> SectionNameOrErr = S.getName();
- if (!SectionNameOrErr) {
- consumeError(SectionNameOrErr.takeError());
- continue;
- }
-
+ StringRef SectionName;
+ S.getName(SectionName);
ArrayRef<uint8_t> sectionData;
- if ((*SectionNameOrErr) != ".debug$S")
+ if (SectionName != ".debug$S")
continue;
const object::coff_section *COFFSection = Obj.getCOFFSection(S);
@@ -159,12 +155,7 @@ void COFFDumper::dumpSections(unsigned N
for (const auto &ObjSection : Obj.sections()) {
const object::coff_section *COFFSection = Obj.getCOFFSection(ObjSection);
COFFYAML::Section NewYAMLSection;
-
- if (Expected<StringRef> NameOrErr = ObjSection.getName())
- NewYAMLSection.Name = *NameOrErr;
- else
- consumeError(NameOrErr.takeError());
-
+ ObjSection.getName(NewYAMLSection.Name);
NewYAMLSection.Header.Characteristics = COFFSection->Characteristics;
NewYAMLSection.Header.VirtualAddress = COFFSection->VirtualAddress;
NewYAMLSection.Header.VirtualSize = COFFSection->VirtualSize;
More information about the llvm-commits
mailing list