[COFF] Fix error handling in ResourceSectionRef

Previously, the expression (Reader.readFoo()) was expanded twice,
triggering asserts as one of the Error types ends up not checked
(and as it was expanded twice, the method would end up called twice
if it failed first).

Differential Revision: https://reviews.llvm.org/D66817

llvm-svn: 370309
This commit is contained in:
Martin Storsjo 2019-08-29 08:59:41 +00:00
parent e3e8874b89
commit 357a40ec7c
1 changed files with 6 additions and 3 deletions

View File

@ -1662,9 +1662,12 @@ std::error_code BaseRelocRef::getRVA(uint32_t &Result) const {
return std::error_code();
}
#define RETURN_IF_ERROR(E) \
if (E) \
return E;
#define RETURN_IF_ERROR(Expr) \
do { \
Error E = (Expr); \
if (E) \
return std::move(E); \
} while (0)
Expected<ArrayRef<UTF16>>
ResourceSectionRef::getDirStringAtOffset(uint32_t Offset) {