Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Error.h « COFF « lld - github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 45c31b801349daee1f0cabcb2bb96f648b92ca26 (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.h ------------------------------------------------------------===//
//
//                             The LLVM Linker
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//

#ifndef LLD_COFF_ERROR_H
#define LLD_COFF_ERROR_H

#include <string>
#include <system_error>
#include "llvm/Support/ErrorHandling.h"

namespace lld {
namespace coff {

enum class LLDError {
  InvalidOption = 1,
  InvalidFile,
  BrokenFile,
  DuplicateSymbols,
};

class LLDErrorCategory : public std::error_category {
public:
  const char *name() const LLVM_NOEXCEPT override { return "lld"; }

  std::string message(int EV) const override {
    switch (static_cast<LLDError>(EV)) {
    case LLDError::InvalidOption:
      return "Invalid option";
    case LLDError::InvalidFile:
      return "Invalid file";
    case LLDError::BrokenFile:
      return "Broken file";
    case LLDError::DuplicateSymbols:
      return "Duplicate symbols";
    }
    llvm_unreachable("unknown error");
  }
};

inline std::error_code make_error_code(LLDError Err) {
  static LLDErrorCategory C;
  return std::error_code(static_cast<int>(Err), C);
}

} // namespace coff
} // namespace lld

#endif