1 //===- Error.h --------------------------------------------------*- C++ -*-===//
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef LLD_COFF_ERROR_H
11 #define LLD_COFF_ERROR_H
13 #include "lld/Core/LLVM.h"
19 extern llvm::raw_ostream *ErrorOS;
21 void log(const Twine &Msg);
22 void warning(const Twine &Msg);
24 void error(const Twine &Msg);
25 void error(std::error_code EC, const Twine &Prefix);
27 template <typename T> void error(const ErrorOr<T> &V, const Twine &Prefix) {
28 error(V.getError(), Prefix);
31 LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg);
32 LLVM_ATTRIBUTE_NORETURN void fatal(const Twine &Msg, const Twine &Prefix);
34 template <class T> T check(ErrorOr<T> E) {
35 if (auto EC = E.getError())
40 template <class T> T check(Expected<T> E) {
42 fatal(errorToErrorCode(E.takeError()).message());
46 template <class T> T check(ErrorOr<T> E, const Twine &Prefix) {
47 if (auto EC = E.getError())
48 fatal(EC.message(), Prefix);
52 template <class T> T check(Expected<T> E, const Twine &Prefix) {
54 fatal(errorToErrorCode(E.takeError()).message(), Prefix);