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 | |
| 14 | #ifndef LLVM_READOBJ_ERROR_H |
| 15 | #define LLVM_READOBJ_ERROR_H |
| 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 | a6e9c3e | 2014-06-12 17:38:55 +0000 | [diff] [blame^] | 20 | using std::error_code; |
Rafael Espindola | 25188c9 | 2014-06-12 01:45:43 +0000 | [diff] [blame] | 21 | const std::error_category &readobj_category(); |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 22 | |
Rafael Espindola | 933c950 | 2014-06-11 01:22:20 +0000 | [diff] [blame] | 23 | enum class readobj_error { |
| 24 | success = 0, |
| 25 | file_not_found, |
| 26 | unsupported_file_format, |
| 27 | unrecognized_file_format, |
| 28 | unsupported_obj_file_format, |
| 29 | unknown_symbol |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | inline error_code make_error_code(readobj_error e) { |
| 33 | return error_code(static_cast<int>(e), readobj_category()); |
| 34 | } |
| 35 | |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 36 | } // namespace llvm |
| 37 | |
Rafael Espindola | 5c4f829 | 2014-06-11 19:05:50 +0000 | [diff] [blame] | 38 | namespace std { |
| 39 | template <> struct is_error_code_enum<llvm::readobj_error> : std::true_type {}; |
| 40 | } |
| 41 | |
Eric Christopher | 9cad53c | 2013-04-03 18:31:38 +0000 | [diff] [blame] | 42 | #endif |