blob: f390e1b96f8a213e313d975d56251823c1fb69ad [file] [log] [blame]
Eric Christopher9cad53c2013-04-03 18:31:38 +00001//===- Error.h - system_error extensions for llvm-readobj -------*- C++ -*-===//
2//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// 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
Eric Christopher9cad53c2013-04-03 18:31:38 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This declares a new error_category for the llvm-readobj tool.
10//
11//===----------------------------------------------------------------------===//
12
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000013#ifndef LLVM_TOOLS_LLVM_READOBJ_ERROR_H
14#define LLVM_TOOLS_LLVM_READOBJ_ERROR_H
Eric Christopher9cad53c2013-04-03 18:31:38 +000015
Rafael Espindolaa6e9c3e2014-06-12 17:38:55 +000016#include <system_error>
Eric Christopher9cad53c2013-04-03 18:31:38 +000017
18namespace llvm {
Rafael Espindola25188c92014-06-12 01:45:43 +000019const std::error_category &readobj_category();
Eric Christopher9cad53c2013-04-03 18:31:38 +000020
Rafael Espindola933c9502014-06-11 01:22:20 +000021enum 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
Eric Christopher9cad53c2013-04-03 18:31:38 +000028};
29
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000030inline std::error_code make_error_code(readobj_error e) {
31 return std::error_code(static_cast<int>(e), readobj_category());
Eric Christopher9cad53c2013-04-03 18:31:38 +000032}
33
Eric Christopher9cad53c2013-04-03 18:31:38 +000034} // namespace llvm
35
Rafael Espindola5c4f8292014-06-11 19:05:50 +000036namespace std {
37template <> struct is_error_code_enum<llvm::readobj_error> : std::true_type {};
38}
39
Eric Christopher9cad53c2013-04-03 18:31:38 +000040#endif