summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp')
-rw-r--r--llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp b/llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
index a565718debd..84e3c634f54 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
+++ b/llvm/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 <cinttypes>
@@ -16,15 +17,6 @@
using namespace llvm;
-// FIXME: There are several versions of this. Consolidate them.
-template <typename... Ts>
-static Error createError(char const *Fmt, const Ts &... Vals) {
- std::string Buffer;
- raw_string_ostream Stream(Buffer);
- Stream << format(Fmt, Vals...);
- return make_error<StringError>(Stream.str(), inconvertibleErrorCode());
-}
-
void DWARFDebugRangeList::clear() {
Offset = -1U;
AddressSize = 0;
@@ -35,11 +27,13 @@ Error DWARFDebugRangeList::extract(const DWARFDataExtractor &data,
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 @@ Error DWARFDebugRangeList::extract(const DWARFDataExtractor &data,
// 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())
OpenPOWER on IntegriCloud