aboutsummaryrefslogtreecommitdiff
path: root/lld/ELF/Error.cpp
blob: 776fc72a25cee03f7e5f4b86b0164e16512b2825 (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
//===- 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 "Config.h"

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

using namespace llvm;

namespace lld {

bool elf::HasError;
raw_ostream *elf::ErrorOS;

void elf::log(const Twine &Msg) {
  if (Config->Verbose)
    outs() << Msg << "\n";
}

void elf::warning(const Twine &Msg) {
  if (Config->FatalWarnings)
    error(Msg);
  else
    *ErrorOS << Msg << "\n";
}

void elf::error(const Twine &Msg) {
  *ErrorOS << Msg << "\n";
  HasError = true;
}

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

void elf::fatal(const Twine &Msg) {
  *ErrorOS << Msg << "\n";
  exit(1);
}

void elf::fatal(const Twine &Msg, const Twine &Prefix) {
  fatal(Prefix + ": " + Msg);
}

} // namespace lld