xref: /aosp_15_r20/external/llvm/tools/llvm-readobj/Error.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //===- Error.h - system_error extensions for llvm-readobj -------*- C++ -*-===//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker //
10*9880d681SAndroid Build Coastguard Worker // This declares a new error_category for the llvm-readobj tool.
11*9880d681SAndroid Build Coastguard Worker //
12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
13*9880d681SAndroid Build Coastguard Worker 
14*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_TOOLS_LLVM_READOBJ_ERROR_H
15*9880d681SAndroid Build Coastguard Worker #define LLVM_TOOLS_LLVM_READOBJ_ERROR_H
16*9880d681SAndroid Build Coastguard Worker 
17*9880d681SAndroid Build Coastguard Worker #include <system_error>
18*9880d681SAndroid Build Coastguard Worker 
19*9880d681SAndroid Build Coastguard Worker namespace llvm {
20*9880d681SAndroid Build Coastguard Worker const std::error_category &readobj_category();
21*9880d681SAndroid Build Coastguard Worker 
22*9880d681SAndroid Build Coastguard Worker enum class readobj_error {
23*9880d681SAndroid Build Coastguard Worker   success = 0,
24*9880d681SAndroid Build Coastguard Worker   file_not_found,
25*9880d681SAndroid Build Coastguard Worker   unsupported_file_format,
26*9880d681SAndroid Build Coastguard Worker   unrecognized_file_format,
27*9880d681SAndroid Build Coastguard Worker   unsupported_obj_file_format,
28*9880d681SAndroid Build Coastguard Worker   unknown_symbol
29*9880d681SAndroid Build Coastguard Worker };
30*9880d681SAndroid Build Coastguard Worker 
make_error_code(readobj_error e)31*9880d681SAndroid Build Coastguard Worker inline std::error_code make_error_code(readobj_error e) {
32*9880d681SAndroid Build Coastguard Worker   return std::error_code(static_cast<int>(e), readobj_category());
33*9880d681SAndroid Build Coastguard Worker }
34*9880d681SAndroid Build Coastguard Worker 
35*9880d681SAndroid Build Coastguard Worker } // namespace llvm
36*9880d681SAndroid Build Coastguard Worker 
37*9880d681SAndroid Build Coastguard Worker namespace std {
38*9880d681SAndroid Build Coastguard Worker template <> struct is_error_code_enum<llvm::readobj_error> : std::true_type {};
39*9880d681SAndroid Build Coastguard Worker }
40*9880d681SAndroid Build Coastguard Worker 
41*9880d681SAndroid Build Coastguard Worker #endif
42