blob: f3e24bbe5dbfd79890fc66806b532e3a7f4cb735 [file] [log] [blame]
Eric Christopher9cad53c2013-04-03 18:31:38 +00001//===- 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 Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_TOOLS_LLVM_READOBJ_ERROR_H
15#define LLVM_TOOLS_LLVM_READOBJ_ERROR_H
Eric Christopher9cad53c2013-04-03 18:31:38 +000016
Rafael Espindolaa6e9c3e2014-06-12 17:38:55 +000017#include <system_error>
Eric Christopher9cad53c2013-04-03 18:31:38 +000018
19namespace llvm {
Rafael Espindola25188c92014-06-12 01:45:43 +000020const std::error_category &readobj_category();
Eric Christopher9cad53c2013-04-03 18:31:38 +000021
Rafael Espindola933c9502014-06-11 01:22:20 +000022enum 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 Christopher9cad53c2013-04-03 18:31:38 +000029};
30
Rafael Espindolabff5d0d2014-06-13 01:25:41 +000031inline std::error_code make_error_code(readobj_error e) {
32 return std::error_code(static_cast<int>(e), readobj_category());
Eric Christopher9cad53c2013-04-03 18:31:38 +000033}
34
Eric Christopher9cad53c2013-04-03 18:31:38 +000035} // namespace llvm
36
Rafael Espindola5c4f8292014-06-11 19:05:50 +000037namespace std {
38template <> struct is_error_code_enum<llvm::readobj_error> : std::true_type {};
39}
40
Eric Christopher9cad53c2013-04-03 18:31:38 +000041#endif