diff options
-rw-r--r-- | lld/ELF/Error.h | 7 | ||||
-rw-r--r-- | lld/include/lld/Core/LLVM.h | 4 |
2 files changed, 11 insertions, 0 deletions
diff --git a/lld/ELF/Error.h b/lld/ELF/Error.h index afa51b98606..45d9113cbd8 100644 --- a/lld/ELF/Error.h +++ b/lld/ELF/Error.h @@ -39,6 +39,13 @@ template <class T> T check(ErrorOr<T> EO) { fatal(EO.getError().message()); } +template <class T> T check(Expected<T> EO) { + if (EO) + return std::move(*EO); + check(errorToErrorCode(EO.takeError())); + return T(); +} + template <class T> T check(ErrorOr<T> EO, const Twine &Prefix) { if (EO) return std::move(*EO); diff --git a/lld/include/lld/Core/LLVM.h b/lld/include/lld/Core/LLVM.h index d532c17fbfd..2f18045e0b6 100644 --- a/lld/include/lld/Core/LLVM.h +++ b/lld/include/lld/Core/LLVM.h @@ -38,6 +38,9 @@ namespace llvm { template<typename T> class ErrorOr; + template<typename T> + class Expected; + class raw_ostream; // TODO: DenseMap, ... } @@ -61,6 +64,7 @@ namespace lld { using llvm::SmallVectorImpl; using llvm::SaveAndRestore; using llvm::ErrorOr; + using llvm::Expected; using llvm::raw_ostream; } // end namespace lld. |