Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 1 | //===- Error.h - system_error extensions for llvm-readobj -------*- C++ -*-===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This declares a new error_category for the llvm-readobj tool. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 13 | #ifndef LLVM_TOOLS_LLVM_READOBJ_ERROR_H |
| 14 | #define LLVM_TOOLS_LLVM_READOBJ_ERROR_H |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 15 | |
Rafael Espindola | a6e9c3e | 2014-06-12 17:38:55 +0000 | [diff] [blame] | 16 | #include <system_error> |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 17 | |
| 18 | namespace llvm { |
Rafael Espindola | 25188c9 | 2014-06-12 01:45:43 +0000 | [diff] [blame] | 19 | const std::error_category &readobj_category(); |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 20 | |
Rafael Espindola | 933c950 | 2014-06-11 01:22:20 +0000 | [diff] [blame] | 21 | enum 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 Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 28 | }; |
| 29 | |
Rafael Espindola | bff5d0d | 2014-06-13 01:25:41 +0000 | [diff] [blame] | 30 | inline std::error_code make_error_code(readobj_error e) { |
| 31 | return std::error_code(static_cast<int>(e), readobj_category()); |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 32 | } |
| 33 | |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 34 | } // namespace llvm |
| 35 | |
Rafael Espindola | 5c4f829 | 2014-06-11 19:05:50 +0000 | [diff] [blame] | 36 | namespace std { |
| 37 | template <> struct is_error_code_enum<llvm::readobj_error> : std::true_type {}; |
| 38 | } |
| 39 | |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 40 | #endif |