diff options
author | Hans Wennborg <hans@hanshq.net> | 2019-05-16 12:08:34 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2019-05-16 12:08:34 +0000 |
commit | 4da9ff9fcfe8987472dc894489597bd338aac85e (patch) | |
tree | 21bc0332451ec4093db5da5255ee98577ac5926e /llvm/tools | |
parent | a8f88c388f75cb03bd21beb0b64f87d8a8727254 (diff) | |
download | bcm5719-llvm-4da9ff9fcfe8987472dc894489597bd338aac85e.tar.gz bcm5719-llvm-4da9ff9fcfe8987472dc894489597bd338aac85e.zip |
Revert r360876 "[Object] Change object::SectionRef::getContents() to return Expected<StringRef>"
It broke the Clang build, see llvm-commits thread.
> Expected<ArrayRef<uint8_t>> may be better but use Expected<StringRef> for now.
>
> Follow-up of D61781.
llvm-svn: 360878
Diffstat (limited to 'llvm/tools')
-rw-r--r-- | llvm/tools/dsymutil/DwarfLinker.cpp | 10 | ||||
-rw-r--r-- | llvm/tools/dsymutil/DwarfStreamer.cpp | 10 | ||||
-rw-r--r-- | llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp | 10 | ||||
-rw-r--r-- | llvm/tools/llvm-cov/TestingSupport.cpp | 13 | ||||
-rw-r--r-- | llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp | 17 | ||||
-rw-r--r-- | llvm/tools/llvm-dwp/llvm-dwp.cpp | 7 | ||||
-rw-r--r-- | llvm/tools/llvm-objdump/MachODump.cpp | 35 | ||||
-rw-r--r-- | llvm/tools/llvm-objdump/llvm-objdump.cpp | 17 | ||||
-rw-r--r-- | llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp | 8 | ||||
-rw-r--r-- | llvm/tools/llvm-pdbutil/InputFile.cpp | 9 | ||||
-rw-r--r-- | llvm/tools/llvm-readobj/COFFDumper.cpp | 26 | ||||
-rw-r--r-- | llvm/tools/llvm-readobj/MachODumper.cpp | 14 | ||||
-rw-r--r-- | llvm/tools/llvm-readobj/ObjDumper.cpp | 6 | ||||
-rw-r--r-- | llvm/tools/sancov/sancov.cpp | 6 |
14 files changed, 96 insertions, 92 deletions
diff --git a/llvm/tools/dsymutil/DwarfLinker.cpp b/llvm/tools/dsymutil/DwarfLinker.cpp index ab666270aa1..c8e70eeb7cc 100644 --- a/llvm/tools/dsymutil/DwarfLinker.cpp +++ b/llvm/tools/dsymutil/DwarfLinker.cpp @@ -436,13 +436,9 @@ static bool isMachOPairedReloc(uint64_t RelocType, uint64_t Arch) { void DwarfLinker::RelocationManager::findValidRelocsMachO( const object::SectionRef &Section, const object::MachOObjectFile &Obj, const DebugMapObject &DMO) { - Expected<StringRef> ContentsOrErr = Section.getContents(); - if (!ContentsOrErr) { - consumeError(ContentsOrErr.takeError()); - Linker.reportWarning("error reading section", DMO); - return; - } - DataExtractor Data(*ContentsOrErr, Obj.isLittleEndian(), 0); + StringRef Contents; + Section.getContents(Contents); + DataExtractor Data(Contents, Obj.isLittleEndian(), 0); bool SkipNext = false; for (const object::RelocationRef &Reloc : Section.relocations()) { diff --git a/llvm/tools/dsymutil/DwarfStreamer.cpp b/llvm/tools/dsymutil/DwarfStreamer.cpp index ccc6a2c852c..fbea7426a52 100644 --- a/llvm/tools/dsymutil/DwarfStreamer.cpp +++ b/llvm/tools/dsymutil/DwarfStreamer.cpp @@ -667,12 +667,10 @@ void DwarfStreamer::translateLineTable(DataExtractor Data, uint32_t Offset, static void emitSectionContents(const object::ObjectFile &Obj, StringRef SecName, MCStreamer *MS) { - if (auto Sec = getSectionByName(Obj, SecName)) { - if (Expected<StringRef> E = Sec->getContents()) - MS->EmitBytes(*E); - else - consumeError(E.takeError()); - } + StringRef Contents; + if (auto Sec = getSectionByName(Obj, SecName)) + if (!Sec->getContents(Contents)) + MS->EmitBytes(Contents); } void DwarfStreamer::copyInvariantDebugSection(const object::ObjectFile &Obj) { diff --git a/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp b/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp index 4bf308f87c2..ff2ce46a01d 100644 --- a/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp +++ b/llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp @@ -453,11 +453,13 @@ Error FileAnalysis::parseCodeSections() { if (!Section.getName(SectionName) && SectionName == ".plt") continue; - Expected<StringRef> Contents = Section.getContents(); - if (!Contents) - return Contents.takeError(); - ArrayRef<uint8_t> SectionBytes = arrayRefFromStringRef(*Contents); + StringRef SectionContents; + if (Section.getContents(SectionContents)) + return make_error<StringError>("Failed to retrieve section contents", + inconvertibleErrorCode()); + ArrayRef<uint8_t> SectionBytes((const uint8_t *)SectionContents.data(), + Section.getSize()); parseSectionContents(SectionBytes, {Section.getAddress(), Section.getIndex()}); } diff --git a/llvm/tools/llvm-cov/TestingSupport.cpp b/llvm/tools/llvm-cov/TestingSupport.cpp index 3ee318c9c64..e2b86c0b79c 100644 --- a/llvm/tools/llvm-cov/TestingSupport.cpp +++ b/llvm/tools/llvm-cov/TestingSupport.cpp @@ -69,18 +69,9 @@ int convertForTestingMain(int argc, const char *argv[]) { uint64_t ProfileNamesAddress = ProfileNames.getAddress(); StringRef CoverageMappingData; StringRef ProfileNamesData; - if (Expected<StringRef> E = CoverageMapping.getContents()) - CoverageMappingData = *E; - else { - consumeError(E.takeError()); + if (CoverageMapping.getContents(CoverageMappingData) || + ProfileNames.getContents(ProfileNamesData)) return 1; - } - if (Expected<StringRef> E = ProfileNames.getContents()) - ProfileNamesData = *E; - else { - consumeError(E.takeError()); - return 1; - } int FD; if (auto Err = sys::fs::openFileForWrite(OutputFilename, FD)) { diff --git a/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp b/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp index 83331265578..c850815cd2f 100644 --- a/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp +++ b/llvm/tools/llvm-cxxdump/llvm-cxxdump.cpp @@ -48,20 +48,15 @@ static void error(std::error_code EC) { exit(1); } -LLVM_ATTRIBUTE_NORETURN static void error(Error Err) { +static void error(Error Err) { + if (!Err) + return; logAllUnhandledErrors(std::move(Err), WithColor::error(outs()), "reading file: "); outs().flush(); exit(1); } -template <typename T> -T unwrapOrError(Expected<T> EO) { - if (!EO) - error(EO.takeError()); - return std::move(*EO); -} - } // namespace llvm static void reportError(StringRef Input, StringRef Message) { @@ -200,7 +195,8 @@ static void dumpCXXData(const ObjectFile *Obj) { // Skip virtual or BSS sections. if (Sec.isBSS() || Sec.isVirtual()) continue; - StringRef SecContents = unwrapOrError(Sec.getContents()); + StringRef SecContents; + error(Sec.getContents(SecContents)); Expected<uint64_t> SymAddressOrErr = Sym.getAddress(); error(errorToErrorCode(SymAddressOrErr.takeError())); uint64_t SymAddress = *SymAddressOrErr; @@ -514,8 +510,7 @@ static void dumpArchive(const Archive *Arc) { else reportError(Arc->getFileName(), cxxdump_error::unrecognized_file_format); } - if (Err) - error(std::move(Err)); + error(std::move(Err)); } static void dumpInput(StringRef File) { diff --git a/llvm/tools/llvm-dwp/llvm-dwp.cpp b/llvm/tools/llvm-dwp/llvm-dwp.cpp index 9715ee32af7..2d6bd7fdd23 100644 --- a/llvm/tools/llvm-dwp/llvm-dwp.cpp +++ b/llvm/tools/llvm-dwp/llvm-dwp.cpp @@ -410,10 +410,9 @@ static Error handleSection( if (std::error_code Err = Section.getName(Name)) return errorCodeToError(Err); - Expected<StringRef> ContentsOrErr = Section.getContents(); - if (!ContentsOrErr) - return ContentsOrErr.takeError(); - StringRef Contents = *ContentsOrErr; + StringRef Contents; + if (auto Err = Section.getContents(Contents)) + return errorCodeToError(Err); if (auto Err = handleCompressedSection(UncompressedSections, Name, Contents)) return Err; diff --git a/llvm/tools/llvm-objdump/MachODump.cpp b/llvm/tools/llvm-objdump/MachODump.cpp index 6bb30c551da..9d8161937b4 100644 --- a/llvm/tools/llvm-objdump/MachODump.cpp +++ b/llvm/tools/llvm-objdump/MachODump.cpp @@ -1482,8 +1482,8 @@ static void DumpLiteralPointerSection(MachOObjectFile *O, section_type = Sec.flags & MachO::SECTION_TYPE; } - StringRef BytesStr = unwrapOrError(Sect->getContents(), O->getFileName()); - + StringRef BytesStr; + Sect->getContents(BytesStr); const char *Contents = reinterpret_cast<const char *>(BytesStr.data()); switch (section_type) { @@ -1697,8 +1697,8 @@ static void DumpSectionContents(StringRef Filename, MachOObjectFile *O, } uint32_t section_type = section_flags & MachO::SECTION_TYPE; - StringRef BytesStr = - unwrapOrError(Section.getContents(), O->getFileName()); + StringRef BytesStr; + Section.getContents(BytesStr); const char *sect = reinterpret_cast<const char *>(BytesStr.data()); uint32_t sect_size = BytesStr.size(); uint64_t sect_addr = Section.getAddress(); @@ -1782,8 +1782,8 @@ static void DumpInfoPlistSectionContents(StringRef Filename, if (SegName == "__TEXT" && SectName == "__info_plist") { if (!NoLeadingHeaders) outs() << "Contents of (" << SegName << "," << SectName << ") section\n"; - StringRef BytesStr = - unwrapOrError(Section.getContents(), O->getFileName()); + StringRef BytesStr; + Section.getContents(BytesStr); const char *sect = reinterpret_cast<const char *>(BytesStr.data()); outs() << format("%.*s", BytesStr.size(), sect) << "\n"; return; @@ -3194,8 +3194,8 @@ static const char *get_pointer_64(uint64_t Address, uint32_t &offset, S = (*(info->Sections))[SectIdx]; offset = Address - SectAddress; left = SectSize - offset; - StringRef SectContents = unwrapOrError( - ((*(info->Sections))[SectIdx]).getContents(), info->O->getFileName()); + StringRef SectContents; + ((*(info->Sections))[SectIdx]).getContents(SectContents); return SectContents.data() + offset; } } @@ -3998,7 +3998,8 @@ walk_pointer_list_64(const char *listname, const SectionRef S, StringRef SegName = O->getSectionFinalSegmentName(Ref); outs() << "Contents of (" << SegName << "," << SectName << ") section\n"; - StringRef BytesStr = unwrapOrError(S.getContents(), O->getFileName()); + StringRef BytesStr; + S.getContents(BytesStr); const char *Contents = reinterpret_cast<const char *>(BytesStr.data()); for (uint32_t i = 0; i < S.getSize(); i += sizeof(uint64_t)) { @@ -4048,7 +4049,8 @@ walk_pointer_list_32(const char *listname, const SectionRef S, StringRef SegName = O->getSectionFinalSegmentName(Ref); outs() << "Contents of (" << SegName << "," << SectName << ") section\n"; - StringRef BytesStr = unwrapOrError(S.getContents(), O->getFileName()); + StringRef BytesStr; + S.getContents(BytesStr); const char *Contents = reinterpret_cast<const char *>(BytesStr.data()); for (uint32_t i = 0; i < S.getSize(); i += sizeof(uint32_t)) { @@ -7240,8 +7242,8 @@ static void DisassembleMachO(StringRef Filename, MachOObjectFile *MachOOF, if (SegmentName != DisSegName) continue; - StringRef BytesStr = - unwrapOrError(Sections[SectIdx].getContents(), Filename); + StringRef BytesStr; + Sections[SectIdx].getContents(BytesStr); ArrayRef<uint8_t> Bytes = arrayRefFromStringRef(BytesStr); uint64_t SectAddress = Sections[SectIdx].getAddress(); @@ -7694,8 +7696,9 @@ printMachOCompactUnwindSection(const MachOObjectFile *Obj, uint32_t PointerSize = Is64 ? sizeof(uint64_t) : sizeof(uint32_t); uint32_t EntrySize = 3 * PointerSize + 2 * sizeof(uint32_t); - StringRef Contents = - unwrapOrError(CompactUnwind.getContents(), Obj->getFileName()); + StringRef Contents; + CompactUnwind.getContents(Contents); + SmallVector<CompactUnwindEntry, 4> CompactUnwinds; // First populate the initial raw offsets, encodings and so on from the entry. @@ -7836,8 +7839,8 @@ static void printMachOUnwindInfoSection(const MachOObjectFile *Obj, outs() << "Contents of __unwind_info section:\n"; - StringRef Contents = - unwrapOrError(UnwindInfo.getContents(), Obj->getFileName()); + StringRef Contents; + UnwindInfo.getContents(Contents); ptrdiff_t Pos = 0; //===---------------------------------- diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp index de26b61697c..3fddfd2d349 100644 --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -1126,8 +1126,9 @@ static void disassembleObject(const Target *TheTarget, const ObjectFile *Obj, SmallString<40> Comments; raw_svector_ostream CommentStream(Comments); - ArrayRef<uint8_t> Bytes = arrayRefFromStringRef( - unwrapOrError(Section.getContents(), Obj->getFileName())); + StringRef BytesStr; + error(Section.getContents(BytesStr)); + ArrayRef<uint8_t> Bytes = arrayRefFromStringRef(BytesStr); uint64_t VMAAdjustment = 0; if (shouldAdjustVA(Section)) @@ -1560,6 +1561,7 @@ void printSectionHeaders(const ObjectFile *Obj) { void printSectionContents(const ObjectFile *Obj) { for (const SectionRef &Section : ToolSectionFilter(*Obj)) { StringRef Name; + StringRef Contents; error(Section.getName(Name)); uint64_t BaseAddr = Section.getAddress(); uint64_t Size = Section.getSize(); @@ -1574,7 +1576,7 @@ void printSectionContents(const ObjectFile *Obj) { continue; } - StringRef Contents = unwrapOrError(Section.getContents(), Obj->getFileName()); + error(Section.getContents(Contents)); // Dump out the content as hex and printable ascii characters. for (std::size_t Addr = 0, End = Contents.size(); Addr < End; Addr += 16) { @@ -1762,8 +1764,8 @@ void printRawClangAST(const ObjectFile *Obj) { if (!ClangASTSection) return; - StringRef ClangASTContents = unwrapOrError( - ClangASTSection.getValue().getContents(), Obj->getFileName()); + StringRef ClangASTContents; + error(ClangASTSection.getValue().getContents(ClangASTContents)); outs().write(ClangASTContents.data(), ClangASTContents.size()); } @@ -1799,8 +1801,9 @@ static void printFaultMaps(const ObjectFile *Obj) { return; } - StringRef FaultMapContents = - unwrapOrError(FaultMapSection.getValue().getContents(), Obj->getFileName()); + StringRef FaultMapContents; + error(FaultMapSection.getValue().getContents(FaultMapContents)); + FaultMapParser FMP(FaultMapContents.bytes_begin(), FaultMapContents.bytes_end()); diff --git a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp index dab1e42c3a2..4ad26bef20c 100644 --- a/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp +++ b/llvm/tools/llvm-pdbutil/DumpOutputStyle.cpp @@ -1376,12 +1376,12 @@ Error DumpOutputStyle::dumpTypesFromObjectFile() { else continue; - Expected<StringRef> ContentsOrErr = S.getContents(); - if (!ContentsOrErr) - return ContentsOrErr.takeError(); + StringRef Contents; + if (auto EC = S.getContents(Contents)) + return errorCodeToError(EC); uint32_t Magic; - BinaryStreamReader Reader(*ContentsOrErr, llvm::support::little); + BinaryStreamReader Reader(Contents, llvm::support::little); if (auto EC = Reader.readInteger(Magic)) return EC; if (Magic != COFF::DEBUG_SECTION_MAGIC) diff --git a/llvm/tools/llvm-pdbutil/InputFile.cpp b/llvm/tools/llvm-pdbutil/InputFile.cpp index bd23bfdbe31..f61d89bd70c 100644 --- a/llvm/tools/llvm-pdbutil/InputFile.cpp +++ b/llvm/tools/llvm-pdbutil/InputFile.cpp @@ -66,20 +66,17 @@ getModuleDebugStream(PDBFile &File, StringRef &ModuleName, uint32_t Index) { static inline bool isCodeViewDebugSubsection(object::SectionRef Section, StringRef Name, BinaryStreamReader &Reader) { - StringRef SectionName; + StringRef SectionName, Contents; if (Section.getName(SectionName)) return false; if (SectionName != Name) return false; - Expected<StringRef> ContentsOrErr = Section.getContents(); - if (!ContentsOrErr) { - consumeError(ContentsOrErr.takeError()); + if (Section.getContents(Contents)) return false; - } - Reader = BinaryStreamReader(*ContentsOrErr, support::little); + Reader = BinaryStreamReader(Contents, support::little); uint32_t Magic; if (Reader.bytesRemaining() < sizeof(uint32_t)) return false; diff --git a/llvm/tools/llvm-readobj/COFFDumper.cpp b/llvm/tools/llvm-readobj/COFFDumper.cpp index 21ceb002857..62f2fc56b56 100644 --- a/llvm/tools/llvm-readobj/COFFDumper.cpp +++ b/llvm/tools/llvm-readobj/COFFDumper.cpp @@ -933,7 +933,8 @@ void COFFDumper::initializeFileAndStringTables(BinaryStreamReader &Reader) { void COFFDumper::printCodeViewSymbolSection(StringRef SectionName, const SectionRef &Section) { - StringRef SectionContents = unwrapOrError(Section.getContents()); + StringRef SectionContents; + error(Section.getContents(SectionContents)); StringRef Data = SectionContents; SmallVector<StringRef, 10> FunctionNames; @@ -1217,7 +1218,8 @@ void COFFDumper::mergeCodeViewTypes(MergingTypeTableBuilder &CVIDs, StringRef SectionName; error(S.getName(SectionName)); if (SectionName == ".debug$T") { - StringRef Data = unwrapOrError(S.getContents()); + StringRef Data; + error(S.getContents(Data)); uint32_t Magic; error(consume(Data, Magic)); if (Magic != 4) @@ -1253,7 +1255,8 @@ void COFFDumper::printCodeViewTypeSection(StringRef SectionName, ListScope D(W, "CodeViewTypes"); W.printNumber("Section", SectionName, Obj->getSectionID(Section)); - StringRef Data = unwrapOrError(Section.getContents()); + StringRef Data; + error(Section.getContents(Data)); if (opts::CodeViewSubsectionBytes) W.printBinaryBlock("Data", Data); @@ -1313,7 +1316,9 @@ void COFFDumper::printSectionHeaders() { if (opts::SectionData && !(Section->Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA)) { - StringRef Data = unwrapOrError(Sec.getContents()); + StringRef Data; + error(Sec.getContents(Data)); + W.printBinaryBlock("SectionData", Data); } } @@ -1655,13 +1660,15 @@ void COFFDumper::printCOFFExports() { void COFFDumper::printCOFFDirectives() { for (const SectionRef &Section : Obj->sections()) { + StringRef Contents; StringRef Name; error(Section.getName(Name)); if (Name != ".drectve") continue; - StringRef Contents = unwrapOrError(Section.getContents()); + error(Section.getContents(Contents)); + W.printString("Directive(s)", Contents); } } @@ -1700,7 +1707,8 @@ void COFFDumper::printCOFFResources() { if (!Name.startswith(".rsrc")) continue; - StringRef Ref = unwrapOrError(S.getContents()); + StringRef Ref; + error(S.getContents(Ref)); if ((Name == ".rsrc") || (Name == ".rsrc$01")) { ResourceSectionRef RSF(Ref); @@ -1826,7 +1834,8 @@ void COFFDumper::printStackMap() const { if (StackMapSection == object::SectionRef()) return; - StringRef StackMapContents = unwrapOrError(StackMapSection.getContents()); + StringRef StackMapContents; + StackMapSection.getContents(StackMapContents); ArrayRef<uint8_t> StackMapContentsArray = arrayRefFromStringRef(StackMapContents); @@ -1852,7 +1861,8 @@ void COFFDumper::printAddrsig() { if (AddrsigSection == object::SectionRef()) return; - StringRef AddrsigContents = unwrapOrError(AddrsigSection.getContents()); + StringRef AddrsigContents; + AddrsigSection.getContents(AddrsigContents); ArrayRef<uint8_t> AddrsigContentsArray(AddrsigContents.bytes_begin(), AddrsigContents.size()); diff --git a/llvm/tools/llvm-readobj/MachODumper.cpp b/llvm/tools/llvm-readobj/MachODumper.cpp index 5149f469aa1..5e82f1c38f7 100644 --- a/llvm/tools/llvm-readobj/MachODumper.cpp +++ b/llvm/tools/llvm-readobj/MachODumper.cpp @@ -483,8 +483,15 @@ void MachODumper::printSectionHeaders(const MachOObjectFile *Obj) { } } - if (opts::SectionData && !Section.isBSS()) - W.printBinaryBlock("SectionData", unwrapOrError(Section.getContents())); + if (opts::SectionData) { + bool IsBSS = Section.isBSS(); + if (!IsBSS) { + StringRef Data; + error(Section.getContents(Data)); + + W.printBinaryBlock("SectionData", Data); + } + } } } @@ -653,7 +660,8 @@ void MachODumper::printStackMap() const { if (StackMapSection == object::SectionRef()) return; - StringRef StackMapContents = unwrapOrError(StackMapSection.getContents()); + StringRef StackMapContents; + StackMapSection.getContents(StackMapContents); ArrayRef<uint8_t> StackMapContentsArray = arrayRefFromStringRef(StackMapContents); diff --git a/llvm/tools/llvm-readobj/ObjDumper.cpp b/llvm/tools/llvm-readobj/ObjDumper.cpp index 4f73cbdf281..15facefaddf 100644 --- a/llvm/tools/llvm-readobj/ObjDumper.cpp +++ b/llvm/tools/llvm-readobj/ObjDumper.cpp @@ -73,7 +73,8 @@ void ObjDumper::printSectionAsString(const object::ObjectFile *Obj, error(E); W.startLine() << "String dump of section '" << SectionName << "':\n"; - StringRef SectionContent = unwrapOrError(Section.getContents()); + StringRef SectionContent; + Section.getContents(SectionContent); const uint8_t *SecContent = SectionContent.bytes_begin(); const uint8_t *CurrentWord = SecContent; @@ -106,7 +107,8 @@ void ObjDumper::printSectionAsHex(const object::ObjectFile *Obj, error(E); W.startLine() << "Hex dump of section '" << SectionName << "':\n"; - StringRef SectionContent = unwrapOrError(Section.getContents()); + StringRef SectionContent; + Section.getContents(SectionContent); const uint8_t *SecContent = SectionContent.bytes_begin(); const uint8_t *SecEnd = SecContent + SectionContent.size(); diff --git a/llvm/tools/sancov/sancov.cpp b/llvm/tools/sancov/sancov.cpp index a385890aaac..31949a7c5bc 100644 --- a/llvm/tools/sancov/sancov.cpp +++ b/llvm/tools/sancov/sancov.cpp @@ -841,9 +841,9 @@ static void getObjectCoveragePoints(const object::ObjectFile &O, if (!SectSize) continue; - Expected<StringRef> BytesStr = Section.getContents(); - failIfError(BytesStr); - ArrayRef<uint8_t> Bytes = arrayRefFromStringRef(*BytesStr); + StringRef BytesStr; + failIfError(Section.getContents(BytesStr)); + ArrayRef<uint8_t> Bytes = arrayRefFromStringRef(BytesStr); for (uint64_t Index = 0, Size = 0; Index < Section.getSize(); Index += Size) { |