176e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher//===- Error.h - system_error extensions for llvm-readobj -------*- C++ -*-===// 276e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher// 376e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher// The LLVM Compiler Infrastructure 476e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher// 576e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher// This file is distributed under the University of Illinois Open Source 676e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher// License. See LICENSE.TXT for details. 776e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher// 876e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher//===----------------------------------------------------------------------===// 976e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher// 1076e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher// This declares a new error_category for the llvm-readobj tool. 1176e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher// 1276e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher//===----------------------------------------------------------------------===// 1376e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher 1437ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines#ifndef LLVM_TOOLS_LLVM_READOBJ_ERROR_H 1537ed9c199ca639565f6ce88105f9e39e898d82d0Stephen Hines#define LLVM_TOOLS_LLVM_READOBJ_ERROR_H 1676e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher 17c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines#include <system_error> 1876e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher 1976e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christophernamespace llvm { 20c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hinesconst std::error_category &readobj_category(); 21c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines 22c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hinesenum class readobj_error { 23c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines success = 0, 24c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines file_not_found, 25c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines unsupported_file_format, 26c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines unrecognized_file_format, 27c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines unsupported_obj_file_format, 28c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines unknown_symbol 2976e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher}; 3076e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher 31c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hinesinline std::error_code make_error_code(readobj_error e) { 32c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines return std::error_code(static_cast<int>(e), readobj_category()); 3376e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher} 3476e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher 3576e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher} // namespace llvm 3676e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher 37c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hinesnamespace std { 38c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hinestemplate <> struct is_error_code_enum<llvm::readobj_error> : std::true_type {}; 39c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines} 40c6a4f5e819217e1e12c458aed8e7b122e23a3a58Stephen Hines 4176e70f340c09ba759ad96d8dfe416b64f24bc287Eric Christopher#endif 42