Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 1 | //===- Error.h - system_error extensions for llvm-readobj -------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This declares a new error_category for the llvm-readobj tool. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 14 | #ifndef LLVM_TOOLS_LLVM_READOBJ_ERROR_H |
| 15 | #define LLVM_TOOLS_LLVM_READOBJ_ERROR_H |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 16 | |
Rafael Espindola | a6e9c3e | 2014-06-12 17:38:55 +0000 | [diff] [blame] | 17 | #include <system_error> |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 18 | |
| 19 | namespace llvm { |
Rafael Espindola | 25188c9 | 2014-06-12 01:45:43 +0000 | [diff] [blame] | 20 | const std::error_category &readobj_category(); |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 21 | |
Rafael Espindola | 933c950 | 2014-06-11 01:22:20 +0000 | [diff] [blame] | 22 | enum class readobj_error { |
| 23 | success = 0, |
| 24 | file_not_found, |
| 25 | unsupported_file_format, |
| 26 | unrecognized_file_format, |
| 27 | unsupported_obj_file_format, |
| 28 | unknown_symbol |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 29 | }; |
| 30 | |
Rafael Espindola | bff5d0d | 2014-06-13 01:25:41 +0000 | [diff] [blame] | 31 | inline std::error_code make_error_code(readobj_error e) { |
| 32 | return std::error_code(static_cast<int>(e), readobj_category()); |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 33 | } |
| 34 | |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 35 | } // namespace llvm |
| 36 | |
Rafael Espindola | 5c4f829 | 2014-06-11 19:05:50 +0000 | [diff] [blame] | 37 | namespace std { |
| 38 | template <> struct is_error_code_enum<llvm::readobj_error> : std::true_type {}; |
| 39 | } |
| 40 | |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 41 | #endif |