summaryrefslogtreecommitdiffstats
path: root/lld/ELF/Error.cpp
blob: e3add1b4068181cf4bc6268a748b572a38eb9506 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
//===- Error.cpp ----------------------------------------------------------===//
//
//                             The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#include "Error.h"

#include "llvm/ADT/Twine.h"
#include "llvm/Support/raw_ostream.h"

namespace lld {
namespace elf2 {

bool HasError;

void warning(const Twine &Msg) { llvm::errs() << Msg << "\n"; }

void error(const Twine &Msg) {
  llvm::errs() << Msg << "\n";
  HasError = true;
}

bool error(std::error_code EC, const Twine &Prefix) {
  if (!EC)
    return false;
  error(Prefix + ": " + EC.message());
  return true;
}

bool error(std::error_code EC) {
  if (!EC)
    return false;
  error(EC.message());
  return true;
}

void fatal(const Twine &Msg) {
  llvm::errs() << Msg << "\n";
  exit(1);
}

void fatal(std::error_code EC, const Twine &Prefix) {
  if (EC)
    fatal(Prefix + ": " + EC.message());
}

void fatal(std::error_code EC) {
  if (EC)
    fatal(EC.message());
}

} // namespace elf2
} // namespace lld
OpenPOWER on IntegriCloud