aboutsummaryrefslogtreecommitdiff
path: root/COFF/Error.h
diff options
context:
space:
mode:
Diffstat (limited to 'COFF/Error.h')
-rw-r--r--COFF/Error.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/COFF/Error.h b/COFF/Error.h
index cb0a185f0..0b2d37527 100644
--- a/COFF/Error.h
+++ b/COFF/Error.h
@@ -11,17 +11,26 @@
#define LLD_COFF_ERROR_H
#include "lld/Core/LLVM.h"
+#include "llvm/Support/Error.h"
namespace lld {
namespace coff {
LLVM_ATTRIBUTE_NORETURN void error(const Twine &Msg);
void error(std::error_code EC, const Twine &Prefix);
+void error(llvm::Error E, const Twine &Prefix);
template <typename T> void error(const ErrorOr<T> &V, const Twine &Prefix) {
error(V.getError(), Prefix);
}
+template <class T> T check(Expected<T> E, const Twine &Prefix) {
+ if (!E)
+ return std::move(*E);
+ error(E.takeError(), Prefix);
+ return T();
+}
+
} // namespace coff
} // namespace lld