diff options
Diffstat (limited to 'lld/ELF/Error.h')
-rw-r--r-- | lld/ELF/Error.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/lld/ELF/Error.h b/lld/ELF/Error.h index 45d9113cbd8..f0faf1b79ed 100644 --- a/lld/ELF/Error.h +++ b/lld/ELF/Error.h @@ -52,6 +52,13 @@ template <class T> T check(ErrorOr<T> EO, const Twine &Prefix) { fatal(EO.getError().message(), Prefix); } +template <class T> T check(Expected<T> EO, const Twine &Prefix) { + if (EO) + return std::move(*EO); + error(errorToErrorCode(EO.takeError()), Prefix); + return T(); +} + } // namespace elf } // namespace lld |