]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lld/COFF/Error.cpp
Merge llvm, clang, compiler-rt, libc++, lld and lldb release_40 branch
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lld / COFF / Error.cpp
1 //===- Error.cpp ----------------------------------------------------------===//
2 //
3 //                             The LLVM Linker
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "Error.h"
11
12 #include "llvm/ADT/Twine.h"
13 #include "llvm/Support/Error.h"
14 #include "llvm/Support/Process.h"
15 #include "llvm/Support/raw_ostream.h"
16
17 #if !defined(_MSC_VER) && !defined(__MINGW32__)
18 #include <unistd.h>
19 #endif
20
21 using namespace llvm;
22
23 namespace lld {
24 namespace coff {
25
26 void fatal(const Twine &Msg) {
27   if (sys::Process::StandardErrHasColors()) {
28     errs().changeColor(raw_ostream::RED, /*bold=*/true);
29     errs() << "error: ";
30     errs().resetColor();
31   } else {
32     errs() << "error: ";
33   }
34   errs() << Msg << "\n";
35
36   outs().flush();
37   errs().flush();
38   _exit(1);
39 }
40
41 void fatal(std::error_code EC, const Twine &Msg) {
42   fatal(Msg + ": " + EC.message());
43 }
44
45 void fatal(llvm::Error &Err, const Twine &Msg) {
46   fatal(errorToErrorCode(std::move(Err)), Msg);
47 }
48
49 } // namespace coff
50 } // namespace lld