[llvm] r315475 - Convert a couple of ErrorOr to Expected. NFC.
Rafael Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 11 10:05:24 PDT 2017
Author: rafael
Date: Wed Oct 11 10:05:24 2017
New Revision: 315475
URL: http://llvm.org/viewvc/llvm-project?rev=315475&view=rev
Log:
Convert a couple of ErrorOr to Expected. NFC.
Modified:
llvm/trunk/include/llvm/Object/COFF.h
llvm/trunk/lib/Object/COFFObjectFile.cpp
Modified: llvm/trunk/include/llvm/Object/COFF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/COFF.h?rev=315475&r1=315474&r2=315475&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/COFF.h (original)
+++ llvm/trunk/include/llvm/Object/COFF.h Wed Oct 11 10:05:24 2017
@@ -1172,8 +1172,8 @@ public:
private:
BinaryByteStream BBS;
- ErrorOr<const coff_resource_dir_table &> getTableAtOffset(uint32_t Offset);
- ErrorOr<ArrayRef<UTF16>> getDirStringAtOffset(uint32_t Offset);
+ Expected<const coff_resource_dir_table &> getTableAtOffset(uint32_t Offset);
+ Expected<ArrayRef<UTF16>> getDirStringAtOffset(uint32_t Offset);
};
// Corresponds to `_FPO_DATA` structure in the PE/COFF spec.
Modified: llvm/trunk/lib/Object/COFFObjectFile.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/COFFObjectFile.cpp?rev=315475&r1=315474&r2=315475&view=diff
==============================================================================
--- llvm/trunk/lib/Object/COFFObjectFile.cpp (original)
+++ llvm/trunk/lib/Object/COFFObjectFile.cpp Wed Oct 11 10:05:24 2017
@@ -1633,11 +1633,12 @@ std::error_code BaseRelocRef::getRVA(uin
return std::error_code();
}
-#define RETURN_IF_ERROR(X) \
- if (auto EC = errorToErrorCode(X)) \
- return EC;
+#define RETURN_IF_ERROR(E) \
+ if (E) \
+ return E;
-ErrorOr<ArrayRef<UTF16>> ResourceSectionRef::getDirStringAtOffset(uint32_t Offset) {
+Expected<ArrayRef<UTF16>>
+ResourceSectionRef::getDirStringAtOffset(uint32_t Offset) {
BinaryStreamReader Reader = BinaryStreamReader(BBS);
Reader.setOffset(Offset);
uint16_t Length;
@@ -1649,10 +1650,11 @@ ErrorOr<ArrayRef<UTF16>> ResourceSection
ErrorOr<ArrayRef<UTF16>>
ResourceSectionRef::getEntryNameString(const coff_resource_dir_entry &Entry) {
- return getDirStringAtOffset(Entry.Identifier.getNameOffset());
+ return expectedToErrorOr(
+ getDirStringAtOffset(Entry.Identifier.getNameOffset()));
}
-ErrorOr<const coff_resource_dir_table &>
+Expected<const coff_resource_dir_table &>
ResourceSectionRef::getTableAtOffset(uint32_t Offset) {
const coff_resource_dir_table *Table = nullptr;
@@ -1665,9 +1667,9 @@ ResourceSectionRef::getTableAtOffset(uin
ErrorOr<const coff_resource_dir_table &>
ResourceSectionRef::getEntrySubDir(const coff_resource_dir_entry &Entry) {
- return getTableAtOffset(Entry.Offset.value());
+ return expectedToErrorOr(getTableAtOffset(Entry.Offset.value()));
}
ErrorOr<const coff_resource_dir_table &> ResourceSectionRef::getBaseTable() {
- return getTableAtOffset(0);
+ return expectedToErrorOr(getTableAtOffset(0));
}
More information about the llvm-commits
mailing list