[llvm-objdump] - Remove one overload of reportError. NFCI.
[llvm-complete.git] / tools / obj2yaml / Error.cpp
blobd11d47b5b227d2af630e91830d7a1b0bbc92c4c5
1 //===- Error.cpp - system_error extensions for obj2yaml ---------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "Error.h"
10 #include "llvm/Support/ErrorHandling.h"
12 using namespace llvm;
14 namespace {
15 // FIXME: This class is only here to support the transition to llvm::Error. It
16 // will be removed once this transition is complete. Clients should prefer to
17 // deal with the Error value directly, rather than converting to error_code.
18 class _obj2yaml_error_category : public std::error_category {
19 public:
20 const char *name() const noexcept override;
21 std::string message(int ev) const override;
23 } // namespace
25 const char *_obj2yaml_error_category::name() const noexcept {
26 return "obj2yaml";
29 std::string _obj2yaml_error_category::message(int ev) const {
30 switch (static_cast<obj2yaml_error>(ev)) {
31 case obj2yaml_error::success:
32 return "Success";
33 case obj2yaml_error::file_not_found:
34 return "No such file.";
35 case obj2yaml_error::unrecognized_file_format:
36 return "Unrecognized file type.";
37 case obj2yaml_error::unsupported_obj_file_format:
38 return "Unsupported object file format.";
39 case obj2yaml_error::not_implemented:
40 return "Feature not yet implemented.";
42 llvm_unreachable("An enumerator of obj2yaml_error does not have a message "
43 "defined.");
46 namespace llvm {
48 const std::error_category &obj2yaml_category() {
49 static _obj2yaml_error_category o;
50 return o;
53 char Obj2YamlError::ID = 0;
55 void Obj2YamlError::log(raw_ostream &OS) const { OS << ErrMsg; }
57 std::error_code Obj2YamlError::convertToErrorCode() const {
58 return std::error_code(static_cast<int>(Code), obj2yaml_category());
61 } // namespace llvm