[PATCH] D65951: [llvm-readobj] - Remove unwrapOrError(ErrorOr<T> EO) helper.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 9 01:31:09 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL368410: [llvm-readobj] - Remove unwrapOrError(ErrorOr<T> EO) helper. (authored by grimar, committed by ).
Herald added a project: LLVM.
Changed prior to commit:
https://reviews.llvm.org/D65951?vs=214144&id=214328#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D65951/new/
https://reviews.llvm.org/D65951
Files:
llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
llvm/trunk/tools/llvm-readobj/llvm-readobj.h
Index: llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
===================================================================
--- llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
+++ llvm/trunk/tools/llvm-readobj/COFFDumper.cpp
@@ -60,6 +60,10 @@
using namespace llvm::support;
using namespace llvm::Win64EH;
+static inline Error createError(const Twine &Err) {
+ return make_error<StringError>(Err, object_error::parse_failed);
+}
+
namespace {
struct LoadConfigTables {
@@ -167,7 +171,7 @@
void printDelayImportedSymbols(
const DelayImportDirectoryEntryRef &I,
iterator_range<imported_symbol_iterator> Range);
- ErrorOr<const coff_resource_dir_entry &>
+ Expected<const coff_resource_dir_entry &>
getResourceDirectoryTableEntry(const coff_resource_dir_table &Table,
uint32_t Index);
@@ -1729,7 +1733,8 @@
uint32_t TotalEntries = 0;
for (int i = 0; i < Table.NumberOfNameEntries + Table.NumberOfIDEntries;
i++) {
- auto Entry = unwrapOrError(getResourceDirectoryTableEntry(Table, i));
+ auto Entry = unwrapOrError(Obj->getFileName(),
+ getResourceDirectoryTableEntry(Table, i));
if (Entry.Offset.isSubDir()) {
StringRef NextLevel;
if (Level == "Name")
@@ -1755,7 +1760,8 @@
// Iterate through level in resource directory tree.
for (int i = 0; i < Table.NumberOfNameEntries + Table.NumberOfIDEntries;
i++) {
- auto Entry = unwrapOrError(getResourceDirectoryTableEntry(Table, i));
+ auto Entry = unwrapOrError(Obj->getFileName(),
+ getResourceDirectoryTableEntry(Table, i));
StringRef Name;
SmallString<20> IDStr;
raw_svector_ostream OS(IDStr);
@@ -1808,11 +1814,11 @@
}
}
-ErrorOr<const coff_resource_dir_entry &>
+Expected<const coff_resource_dir_entry &>
COFFDumper::getResourceDirectoryTableEntry(const coff_resource_dir_table &Table,
uint32_t Index) {
if (Index >= (uint32_t)(Table.NumberOfNameEntries + Table.NumberOfIDEntries))
- return object_error::parse_failed;
+ return createError("can't get resource directory table entry");
auto TablePtr = reinterpret_cast<const coff_resource_dir_entry *>(&Table + 1);
return TablePtr[Index];
}
Index: llvm/trunk/tools/llvm-readobj/llvm-readobj.h
===================================================================
--- llvm/trunk/tools/llvm-readobj/llvm-readobj.h
+++ llvm/trunk/tools/llvm-readobj/llvm-readobj.h
@@ -33,12 +33,6 @@
return std::move(*E);
}
- template <class T> T unwrapOrError(ErrorOr<T> EO) {
- if (EO)
- return *EO;
- reportError(EO.getError().message());
- }
-
// TODO: This one is deprecated. Use one with a Input name below.
template <class T> T unwrapOrError(Expected<T> EO) {
if (EO)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65951.214328.patch
Type: text/x-patch
Size: 2846 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190809/acf09f3e/attachment.bin>
More information about the llvm-commits
mailing list