1//===- Error.h - system_error extensions for llvm-readobj -------*- 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//===----------------------------------------------------------------------===//
8//
9// This declares a new error_category for the llvm-readobj tool.
10//
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_TOOLS_LLVM_READOBJ_ERROR_H
14#define LLVM_TOOLS_LLVM_READOBJ_ERROR_H
15
16#include <system_error>
17
18namespace llvm {
19const std::error_category &readobj_category();
20
21enum class readobj_error {
22  success = 0,
23  file_not_found,
24  unsupported_file_format,
25  unrecognized_file_format,
26  unsupported_obj_file_format,
27  unknown_symbol
28};
29
30inline std::error_code make_error_code(readobj_error e) {
31  return std::error_code(static_cast<int>(e), readobj_category());
32}
33
34} // namespace llvm
35
36namespace std {
37template <> struct is_error_code_enum<llvm::readobj_error> : std::true_type {};
38}
39
40#endif
41