blob: 327bb26a4f16a4bcfe50fefe071d372e5d72ab6c [file] [log] [blame]
Rafael Espindola192e1fa2015-08-06 15:08:23 +00001//===- 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/raw_ostream.h"
14
15namespace lld {
16namespace elf2 {
17
Rui Ueyama64cfffd2016-01-28 18:40:06 +000018bool HasError;
19
Rui Ueyamad5b5ab72015-09-24 18:55:33 +000020void warning(const Twine &Msg) { llvm::errs() << Msg << "\n"; }
21
Rafael Espindola192e1fa2015-08-06 15:08:23 +000022void error(const Twine &Msg) {
23 llvm::errs() << Msg << "\n";
Rui Ueyama64cfffd2016-01-28 18:40:06 +000024 HasError = true;
Rafael Espindola192e1fa2015-08-06 15:08:23 +000025}
26
27void error(std::error_code EC, const Twine &Prefix) {
Rui Ueyama64cfffd2016-01-28 18:40:06 +000028 if (EC)
29 error(Prefix + ": " + EC.message());
Rafael Espindola192e1fa2015-08-06 15:08:23 +000030}
31
32void error(std::error_code EC) {
Rui Ueyama64cfffd2016-01-28 18:40:06 +000033 if (EC)
34 error(EC.message());
35}
36
37void fatal(const Twine &Msg) {
38 llvm::errs() << Msg << "\n";
39 exit(1);
40}
41
42void fatal(std::error_code EC, const Twine &Prefix) {
43 if (EC)
44 fatal(Prefix + ": " + EC.message());
45}
46
47void fatal(std::error_code EC) {
48 if (EC)
49 fatal(EC.message());
Rafael Espindola192e1fa2015-08-06 15:08:23 +000050}
51
52} // namespace elf2
53} // namespace lld