Index: include/llvm/DebugInfo/DWARF/DWARFListTable.h =================================================================== --- include/llvm/DebugInfo/DWARF/DWARFListTable.h +++ include/llvm/DebugInfo/DWARF/DWARFListTable.h @@ -13,6 +13,7 @@ #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/DebugInfo/DIContext.h" #include "llvm/DebugInfo/DWARF/DWARFDataExtractor.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/Error.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" @@ -43,10 +44,6 @@ ListEntries Entries; public: - // FIXME: We need to consolidate the various verions of "createError" - // that are used in the DWARF consumer. Until then, this is a workaround. - Error createError(const char *, const char *, uint32_t); - const ListEntries &getEntries() const { return Entries; } bool empty() const { return Entries.empty(); } void clear() { Entries.clear(); } @@ -213,7 +210,8 @@ StringRef SectionName, StringRef ListTypeString) { if (*OffsetPtr < HeaderOffset || *OffsetPtr >= End) - return createError("invalid %s list offset 0x%" PRIx32, + return createStringError(errc::invalid_argument, + "invalid %s list offset 0x%" PRIx32, ListTypeString.data(), *OffsetPtr); Entries.clear(); while (*OffsetPtr < End) { @@ -224,7 +222,8 @@ if (Entry.isSentinel()) return Error::success(); } - return createError("no end of list marker detected at end of %s table " + return createStringError(errc::invalid_argument, + "no end of list marker detected at end of %s table " "starting at offset 0x%" PRIx32, SectionName.data(), HeaderOffset); } Index: lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp +++ lib/DebugInfo/DWARF/DWARFAcceleratorTable.cpp @@ -14,6 +14,7 @@ #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/DJB.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/Format.h" #include "llvm/Support/FormatVariadic.h" #include "llvm/Support/ScopedPrinter.h" @@ -45,9 +46,9 @@ uint32_t Offset = 0; // Check that we can at least read the header. - if (!AccelSection.isValidOffset(offsetof(Header, HeaderDataLength)+4)) - return make_error("Section too small: cannot read header.", - inconvertibleErrorCode()); + if (!AccelSection.isValidOffset(offsetof(Header, HeaderDataLength) + 4)) + return createStringError(errc::illegal_byte_sequence, + "Section too small: cannot read header."); Hdr.Magic = AccelSection.getU32(&Offset); Hdr.Version = AccelSection.getU16(&Offset); @@ -62,9 +63,9 @@ // equal to the size for an empty table and hence pointer after the section. if (!AccelSection.isValidOffset(sizeof(Hdr) + Hdr.HeaderDataLength + Hdr.BucketCount * 4 + Hdr.HashCount * 8 - 1)) - return make_error( - "Section too small: cannot read buckets and hashes.", - inconvertibleErrorCode()); + return createStringError( + errc::illegal_byte_sequence, + "Section too small: cannot read buckets and hashes."); HdrData.DIEOffsetBase = AccelSection.getU32(&Offset); uint32_t NumAtoms = AccelSection.getU32(&Offset); @@ -380,8 +381,8 @@ uint32_t *Offset) { // Check that we can read the fixed-size part. if (!AS.isValidOffset(*Offset + sizeof(HeaderPOD) - 1)) - return make_error("Section too small: cannot read header.", - inconvertibleErrorCode()); + return createStringError(errc::illegal_byte_sequence, + "Section too small: cannot read header."); UnitLength = AS.getU32(Offset); Version = AS.getU16(Offset); @@ -395,9 +396,9 @@ AugmentationStringSize = alignTo(AS.getU32(Offset), 4); if (!AS.isValidOffsetForDataOfSize(*Offset, AugmentationStringSize)) - return make_error( - "Section too small: cannot read header augmentation.", - inconvertibleErrorCode()); + return createStringError( + errc::illegal_byte_sequence, + "Section too small: cannot read header augmentation."); AugmentationString.resize(AugmentationStringSize); AS.getU8(Offset, reinterpret_cast(AugmentationString.data()), AugmentationStringSize); @@ -439,8 +440,8 @@ Expected DWARFDebugNames::NameIndex::extractAttributeEncoding(uint32_t *Offset) { if (*Offset >= EntriesBase) { - return make_error("Incorrectly terminated abbreviation table.", - inconvertibleErrorCode()); + return createStringError(errc::illegal_byte_sequence, + "Incorrectly terminated abbreviation table."); } uint32_t Index = Section.AccelSection.getULEB128(Offset); @@ -465,8 +466,8 @@ Expected DWARFDebugNames::NameIndex::extractAbbrev(uint32_t *Offset) { if (*Offset >= EntriesBase) { - return make_error("Incorrectly terminated abbreviation table.", - inconvertibleErrorCode()); + return createStringError(errc::illegal_byte_sequence, + "Incorrectly terminated abbreviation table."); } uint32_t Code = Section.AccelSection.getULEB128(Offset); @@ -501,9 +502,8 @@ Offset += Hdr.NameCount * 4; if (!AS.isValidOffsetForDataOfSize(Offset, Hdr.AbbrevTableSize)) - return make_error( - "Section too small: cannot read abbreviations.", - inconvertibleErrorCode()); + return createStringError(errc::illegal_byte_sequence, + "Section too small: cannot read abbreviations."); EntriesBase = Offset + Hdr.AbbrevTableSize; @@ -514,10 +514,9 @@ if (isSentinel(*AbbrevOr)) return Error::success(); - if (!Abbrevs.insert(std::move(*AbbrevOr)).second) { - return make_error("Duplicate abbreviation code.", - inconvertibleErrorCode()); - } + if (!Abbrevs.insert(std::move(*AbbrevOr)).second) + return createStringError(errc::invalid_argument, + "Duplicate abbreviation code."); } } DWARFDebugNames::Entry::Entry(const NameIndex &NameIdx, const Abbrev &Abbr) @@ -600,8 +599,8 @@ DWARFDebugNames::NameIndex::getEntry(uint32_t *Offset) const { const DWARFDataExtractor &AS = Section.AccelSection; if (!AS.isValidOffset(*Offset)) - return make_error("Incorrectly terminated entry list.", - inconvertibleErrorCode()); + return createStringError(errc::illegal_byte_sequence, + "Incorrectly terminated entry list."); uint32_t AbbrevCode = AS.getULEB128(Offset); if (AbbrevCode == 0) @@ -609,16 +608,15 @@ const auto AbbrevIt = Abbrevs.find_as(AbbrevCode); if (AbbrevIt == Abbrevs.end()) - return make_error("Invalid abbreviation.", - inconvertibleErrorCode()); + return createStringError(errc::invalid_argument, "Invalid abbreviation."); Entry E(*this, *AbbrevIt); dwarf::FormParams FormParams = {Hdr.Version, 0, dwarf::DwarfFormat::DWARF32}; for (auto &Value : E.Values) { if (!Value.extractValue(AS, Offset, FormParams)) - return make_error("Error extracting index attribute values.", - inconvertibleErrorCode()); + return createStringError(errc::io_error, + "Error extracting index attribute values."); } return std::move(E); } Index: lib/DebugInfo/DWARF/DWARFContext.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFContext.cpp +++ lib/DebugInfo/DWARF/DWARFContext.cpp @@ -1598,7 +1598,8 @@ const Target *TheTarget = TargetRegistry::lookupTarget(TT.str(), TargetLookupError); if (!TargetLookupError.empty()) - return make_error(TargetLookupError, inconvertibleErrorCode()); + return createStringError(errc::invalid_argument, + TargetLookupError.c_str()); RegInfo.reset(TheTarget->createMCRegInfo(TT.str())); return Error::success(); } Index: lib/DebugInfo/DWARF/DWARFDebugFrame.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugFrame.cpp +++ lib/DebugInfo/DWARF/DWARFDebugFrame.cpp @@ -16,6 +16,7 @@ #include "llvm/Support/Casting.h" #include "llvm/Support/Compiler.h" #include "llvm/Support/DataExtractor.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" @@ -47,9 +48,9 @@ uint64_t Op1 = Opcode & DWARF_CFI_PRIMARY_OPERAND_MASK; switch (Primary) { default: - return make_error( - "Invalid primary CFI opcode", - std::make_error_code(std::errc::illegal_byte_sequence)); + return createStringError(errc::illegal_byte_sequence, + "Invalid primary CFI opcode 0x%" PRIx8, + Primary); case DW_CFA_advance_loc: case DW_CFA_restore: addInstruction(Primary, Op1); @@ -62,9 +63,9 @@ // Extended opcode - its value is Opcode itself. switch (Opcode) { default: - return make_error( - "Invalid extended CFI opcode", - std::make_error_code(std::errc::illegal_byte_sequence)); + return createStringError(errc::illegal_byte_sequence, + "Invalid extended CFI opcode 0x%" PRIx8, + Opcode); case DW_CFA_nop: case DW_CFA_remember_state: case DW_CFA_restore_state: Index: lib/DebugInfo/DWARF/DWARFDebugLine.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugLine.cpp +++ lib/DebugInfo/DWARF/DWARFDebugLine.cpp @@ -15,6 +15,7 @@ #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/DebugInfo/DWARF/DWARFFormValue.h" #include "llvm/DebugInfo/DWARF/DWARFRelocMap.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/Format.h" #include "llvm/Support/Path.h" #include "llvm/Support/WithColor.h" @@ -273,24 +274,6 @@ return true; } -template -static std::string formatErrorString(char const *Fmt, const Ts &... Vals) { - std::string Buffer; - raw_string_ostream Stream(Buffer); - Stream << format(Fmt, Vals...); - return Stream.str(); -} - -template -static Error createError(char const *Fmt, const Ts &... Vals) { - return make_error(formatErrorString(Fmt, Vals...), - inconvertibleErrorCode()); -} - -static Error createError(char const *Msg) { - return make_error(Msg, inconvertibleErrorCode()); -} - Error DWARFDebugLine::Prologue::parse(const DWARFDataExtractor &DebugLineData, uint32_t *OffsetPtr, const DWARFContext &Ctx, @@ -303,14 +286,15 @@ FormParams.Format = dwarf::DWARF64; TotalLength = DebugLineData.getU64(OffsetPtr); } else if (TotalLength >= 0xffffff00) { - return createError( + return createStringError(errc::invalid_argument, "parsing line table prologue at offset 0x%8.8" PRIx64 " unsupported reserved unit length found of value 0x%8.8" PRIx64, PrologueOffset, TotalLength); } FormParams.Version = DebugLineData.getU16(OffsetPtr); if (getVersion() < 2) - return createError("parsing line table prologue at offset 0x%8.8" PRIx64 + return createStringError(errc::not_supported, + "parsing line table prologue at offset 0x%8.8" PRIx64 " found unsupported version 0x%2.2" PRIx16, PrologueOffset, getVersion()); @@ -342,7 +326,7 @@ if (!parseV5DirFileTables(DebugLineData, OffsetPtr, EndPrologueOffset, FormParams, Ctx, U, ContentTypes, IncludeDirectories, FileNames)) { - return createError( + return createStringError(errc::invalid_argument, "parsing line table prologue at 0x%8.8" PRIx64 " found an invalid directory or file table description at" " 0x%8.8" PRIx64, @@ -353,7 +337,8 @@ ContentTypes, IncludeDirectories, FileNames); if (*OffsetPtr != EndPrologueOffset) - return createError("parsing line table prologue at 0x%8.8" PRIx64 + return createStringError(errc::invalid_argument, + "parsing line table prologue at 0x%8.8" PRIx64 " should have ended at 0x%8.8" PRIx64 " but it ended at 0x%8.8" PRIx64, PrologueOffset, EndPrologueOffset, (uint64_t)*OffsetPtr); @@ -470,7 +455,7 @@ DWARFDataExtractor &DebugLineData, uint32_t Offset, const DWARFContext &Ctx, const DWARFUnit *U, std::function RecoverableErrorCallback) { if (!DebugLineData.isValidOffset(Offset)) - return createError("offset 0x%8.8" PRIx32 + return createStringError(errc::invalid_argument, "offset 0x%8.8" PRIx32 " is not a valid debug line section offset", Offset); @@ -575,7 +560,8 @@ if (DebugLineData.getAddressSize() == 0) DebugLineData.setAddressSize(Len - 1); else if (DebugLineData.getAddressSize() != Len - 1) { - return createError("mismatching address size at offset 0x%8.8" PRIx32 + return createStringError(errc::invalid_argument, + "mismatching address size at offset 0x%8.8" PRIx32 " expected 0x%2.2" PRIx8 " found 0x%2.2" PRIx64, ExtOffset, DebugLineData.getAddressSize(), Len - 1); @@ -640,7 +626,8 @@ // Make sure the stated and parsed lengths are the same. // Otherwise we have an unparseable line-number program. if (*OffsetPtr - ExtOffset != Len) - return createError("unexpected line op length at offset 0x%8.8" PRIx32 + return createStringError(errc::illegal_byte_sequence, + "unexpected line op length at offset 0x%8.8" PRIx32 " expected 0x%2.2" PRIx64 " found 0x%2.2" PRIx32, ExtOffset, Len, *OffsetPtr - ExtOffset); } else if (Opcode < Prologue.OpcodeBase) { @@ -847,7 +834,8 @@ if (!State.Sequence.Empty) RecoverableErrorCallback( - createError("last sequence in debug line table is not terminated!")); + createStringError(errc::illegal_byte_sequence, + "last sequence in debug line table is not terminated!")); // Sort all sequences so that address lookup will work faster. if (!Sequences.empty()) { Index: lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp +++ lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp @@ -9,6 +9,7 @@ #include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h" #include "llvm/DebugInfo/DWARF/DWARFContext.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" #include @@ -16,15 +17,6 @@ using namespace llvm; -// FIXME: There are several versions of this. Consolidate them. -template -static Error createError(char const *Fmt, const Ts &... Vals) { - std::string Buffer; - raw_string_ostream Stream(Buffer); - Stream << format(Fmt, Vals...); - return make_error(Stream.str(), inconvertibleErrorCode()); -} - void DWARFDebugRangeList::clear() { Offset = -1U; AddressSize = 0; @@ -35,11 +27,13 @@ uint32_t *offset_ptr) { clear(); if (!data.isValidOffset(*offset_ptr)) - return createError("invalid range list offset 0x%" PRIx32, *offset_ptr); + return createStringError(errc::invalid_argument, + "invalid range list offset 0x%" PRIx32, *offset_ptr); AddressSize = data.getAddressSize(); if (AddressSize != 4 && AddressSize != 8) - return createError("invalid address size: %d", AddressSize); + return createStringError(errc::invalid_argument, + "invalid address size: %" PRIu8, AddressSize); Offset = *offset_ptr; while (true) { RangeListEntry Entry; @@ -53,7 +47,8 @@ // Check that both values were extracted correctly. if (*offset_ptr != prev_offset + 2 * AddressSize) { clear(); - return createError("invalid range list entry at offset 0x%" PRIx32, + return createStringError(errc::invalid_argument, + "invalid range list entry at offset 0x%" PRIx32, prev_offset); } if (Entry.isEndOfListEntry()) Index: lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp +++ lib/DebugInfo/DWARF/DWARFDebugRnglists.cpp @@ -10,28 +10,13 @@ #include "llvm/DebugInfo/DWARF/DWARFDebugRnglists.h" #include "llvm/BinaryFormat/Dwarf.h" #include "llvm/DebugInfo/DWARF/DWARFUnit.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/Error.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; -template -static Error createError(char const *Fmt, const Ts &... Vals) { - std::string Buffer; - raw_string_ostream Stream(Buffer); - Stream << format(Fmt, Vals...); - return make_error(Stream.str(), inconvertibleErrorCode()); -} - -namespace llvm { // workaround for gcc bug -template <> -Error DWARFListType::createError(const char *Fmt, const char *s, - uint32_t Val) { - return ::createError(Fmt, s, Val); -} -} - Error RangeListEntry::extract(DWARFDataExtractor Data, uint32_t End, uint32_t *OffsetPtr) { Offset = *OffsetPtr; @@ -48,15 +33,18 @@ break; // TODO: Support other encodings. case dwarf::DW_RLE_base_addressx: - return createError("unsupported rnglists encoding DW_RLE_base_addressx " + return createStringError(errc::not_supported, + "unsupported rnglists encoding DW_RLE_base_addressx " "at offset 0x%" PRIx32, *OffsetPtr - 1); case dwarf::DW_RLE_startx_endx: - return createError("unsupported rnglists encoding DW_RLE_startx_endx at " + return createStringError(errc::not_supported, + "unsupported rnglists encoding DW_RLE_startx_endx at " "offset 0x%" PRIx32, *OffsetPtr - 1); case dwarf::DW_RLE_startx_length: - return createError("unsupported rnglists encoding DW_RLE_startx_length " + return createStringError(errc::not_supported, + "unsupported rnglists encoding DW_RLE_startx_length " "at offset 0x%" PRIx32, *OffsetPtr - 1); case dwarf::DW_RLE_offset_pair: { @@ -64,14 +52,16 @@ Value0 = Data.getULEB128(OffsetPtr); Value1 = Data.getULEB128(OffsetPtr); if (End < *OffsetPtr) - return createError("read past end of table when reading " + return createStringError(errc::invalid_argument, + "read past end of table when reading " "DW_RLE_offset_pair encoding at offset 0x%" PRIx32, PreviousOffset); break; } case dwarf::DW_RLE_base_address: { if ((End - *OffsetPtr) < Data.getAddressSize()) - return createError("insufficient space remaining in table for " + return createStringError(errc::invalid_argument, + "insufficient space remaining in table for " "DW_RLE_base_address encoding at offset 0x%" PRIx32, *OffsetPtr - 1); Value0 = Data.getRelocatedAddress(OffsetPtr, &SectionIndex); @@ -79,7 +69,8 @@ } case dwarf::DW_RLE_start_end: { if ((End - *OffsetPtr) < unsigned(Data.getAddressSize() * 2)) - return createError("insufficient space remaining in table for " + return createStringError(errc::invalid_argument, + "insufficient space remaining in table for " "DW_RLE_start_end encoding " "at offset 0x%" PRIx32, *OffsetPtr - 1); @@ -92,13 +83,15 @@ Value0 = Data.getRelocatedAddress(OffsetPtr, &SectionIndex); Value1 = Data.getULEB128(OffsetPtr); if (End < *OffsetPtr) - return createError("read past end of table when reading " + return createStringError(errc::invalid_argument, + "read past end of table when reading " "DW_RLE_start_length encoding at offset 0x%" PRIx32, PreviousOffset); break; } default: - return createError("unknown rnglists encoding 0x%" PRIx32 + return createStringError(errc::not_supported, + "unknown rnglists encoding 0x%" PRIx32 " at offset 0x%" PRIx32, uint32_t(Encoding), *OffsetPtr - 1); } Index: lib/DebugInfo/DWARF/DWARFListTable.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFListTable.cpp +++ lib/DebugInfo/DWARF/DWARFListTable.cpp @@ -9,42 +9,39 @@ #include "llvm/DebugInfo/DWARF/DWARFListTable.h" #include "llvm/BinaryFormat/Dwarf.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/Error.h" #include "llvm/Support/Format.h" #include "llvm/Support/raw_ostream.h" using namespace llvm; -template -static Error createError(char const *Fmt, const Ts &... Vals) { - std::string Buffer; - raw_string_ostream Stream(Buffer); - Stream << format(Fmt, Vals...); - return make_error(Stream.str(), inconvertibleErrorCode()); -} - Error DWARFListTableHeader::extract(DWARFDataExtractor Data, uint32_t *OffsetPtr) { HeaderOffset = *OffsetPtr; // Read and verify the length field. if (!Data.isValidOffsetForDataOfSize(*OffsetPtr, sizeof(uint32_t))) - return createError("section is not large enough to contain a " + return createStringError(errc::invalid_argument, + "section is not large enough to contain a " "%s table length at offset 0x%" PRIx32, SectionName.data(), *OffsetPtr); // TODO: Add support for DWARF64. HeaderData.Length = Data.getU32(OffsetPtr); if (HeaderData.Length == 0xffffffffu) - return createError("DWARF64 is not supported in %s at offset 0x%" PRIx32, + return createStringError(errc::not_supported, + "DWARF64 is not supported in %s at offset 0x%" PRIx32, SectionName.data(), HeaderOffset); Format = dwarf::DwarfFormat::DWARF32; if (HeaderData.Length + sizeof(uint32_t) < sizeof(Header)) - return createError("%s table at offset 0x%" PRIx32 + return createStringError(errc::invalid_argument, + "%s table at offset 0x%" PRIx32 " has too small length (0x%" PRIx32 ") to contain a complete header", SectionName.data(), HeaderOffset, length()); uint32_t End = HeaderOffset + length(); if (!Data.isValidOffsetForDataOfSize(HeaderOffset, End - HeaderOffset)) - return createError("section is not large enough to contain a %s table " + return createStringError(errc::invalid_argument, + "section is not large enough to contain a %s table " "of length 0x%" PRIx32 " at offset 0x%" PRIx32, SectionName.data(), length(), HeaderOffset); @@ -55,20 +52,23 @@ // Perform basic validation of the remaining header fields. if (HeaderData.Version != 5) - return createError("unrecognised %s table version %" PRIu16 + return createStringError(errc::invalid_argument, + "unrecognised %s table version %" PRIu16 " in table at offset 0x%" PRIx32, SectionName.data(), HeaderData.Version, HeaderOffset); if (HeaderData.AddrSize != 4 && HeaderData.AddrSize != 8) - return createError("%s table at offset 0x%" PRIx32 - " has unsupported address size %hhu", + return createStringError(errc::not_supported, + "%s table at offset 0x%" PRIx32 + " has unsupported address size %" PRIu8, SectionName.data(), HeaderOffset, HeaderData.AddrSize); if (HeaderData.SegSize != 0) - return createError("%s table at offset 0x%" PRIx32 + return createStringError(errc::not_supported, + "%s table at offset 0x%" PRIx32 " has unsupported segment selector size %" PRIu8, SectionName.data(), HeaderOffset, HeaderData.SegSize); if (End < HeaderOffset + sizeof(HeaderData) + HeaderData.OffsetEntryCount * sizeof(uint32_t)) - return createError( + return createStringError(errc::invalid_argument, "%s table at offset 0x%" PRIx32 " has more offset entries (%" PRIu32 ") than there is space for", SectionName.data(), HeaderOffset, HeaderData.OffsetEntryCount); Index: lib/DebugInfo/DWARF/DWARFUnit.cpp =================================================================== --- lib/DebugInfo/DWARF/DWARFUnit.cpp +++ lib/DebugInfo/DWARF/DWARFUnit.cpp @@ -20,6 +20,7 @@ #include "llvm/DebugInfo/DWARF/DWARFFormValue.h" #include "llvm/DebugInfo/DWARF/DWARFTypeUnit.h" #include "llvm/Support/DataExtractor.h" +#include "llvm/Support/Errc.h" #include "llvm/Support/Path.h" #include "llvm/Support/WithColor.h" #include @@ -268,13 +269,10 @@ // We are expected to be called with Offset 0 or pointing just past the table // header, which is 12 bytes long for DWARF32. if (Offset > 0) { - if (Offset < 12U) { - std::string Buffer; - raw_string_ostream Stream(Buffer); - Stream << format( - "Did not detect a valid range list table with base = 0x%x", Offset); - return make_error(Stream.str(), inconvertibleErrorCode()); - } + if (Offset < 12U) + return createStringError(errc::invalid_argument, "Did not detect a valid" + " range list table with base = 0x%" PRIu32, + Offset); Offset -= 12U; } llvm::DWARFDebugRnglistTable Table; @@ -518,8 +516,8 @@ return RangeListOrError.takeError(); } - return make_error("missing or invalid range list table", - inconvertibleErrorCode()); + return createStringError(errc::invalid_argument, + "missing or invalid range list table"); } Expected @@ -527,13 +525,12 @@ if (auto Offset = getRnglistOffset(Index)) return findRnglistFromOffset(*Offset + RangeSectionBase); - std::string Buffer; - raw_string_ostream Stream(Buffer); if (RngListTable) - Stream << format("invalid range list table index %d", Index); + return createStringError(errc::invalid_argument, + "invalid range list table index %d", Index); else - Stream << "missing or invalid range list table"; - return make_error(Stream.str(), inconvertibleErrorCode()); + return createStringError(errc::invalid_argument, + "missing or invalid range list table"); } void DWARFUnit::collectAddressRanges(DWARFAddressRangesVector &CURanges) {