summaryrefslogtreecommitdiffstats
path: root/llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
diff options
context:
space:
mode:
authorVictor Leschuk <vleschuk@accesssoftek.com>2018-08-20 09:59:08 +0000
committerVictor Leschuk <vleschuk@accesssoftek.com>2018-08-20 09:59:08 +0000
commitcba595da825c3a21070b3f9519ae608d8060fb83 (patch)
tree37611d927ef99175f72073b5a0dea4eead4b3e5c /llvm/lib/DebugInfo/DWARF/DWARFDebugRangeList.cpp
parentbbd2d15d45bc455e3dda62bb8a194ff7a969df68 (diff)
downloadbcm5719-llvm-cba595da825c3a21070b3f9519ae608d8060fb83.tar.gz
bcm5719-llvm-cba595da825c3a21070b3f9519ae608d8060fb83.zip
[DWARF] Refactor DWARF classes to use unified error reporting. NFC.
DWARF-related classes in lib/DebugInfo/DWARF contained duplicating code for creating StringError instances, like: 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()); } Similar function was placed in Support lib in https://reviews.llvm.org/D49824 This revision makes DWARF classes use this function instead of their local implementation of it. Reviewers: aprantl, dblaikie, probinson, wolfgangp, JDevlieghere, jhenderson Reviewed By: JDevlieghere, jhenderson Differential Revision: https://reviews.llvm.org/D49964 llvm-svn: 340163
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