LLVM API Documentation
00001 //===- llvm/Support/Errc.h - Defines the llvm::errc enum --------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // While std::error_code works OK on all platforms we use, there are some 00011 // some problems with std::errc that can be avoided by using our own 00012 // enumeration: 00013 // 00014 // * std::errc is a namespace in some implementations. That meas that ADL 00015 // doesn't work and it is sometimes necessary to write std::make_error_code 00016 // or in templates: 00017 // using std::make_error_code; 00018 // make_error_code(...); 00019 // 00020 // with this enum it is safe to always just use make_error_code. 00021 // 00022 // * Some implementations define fewer names than others. This header has 00023 // the intersection of all the ones we support. 00024 // 00025 // * std::errc is just marked with is_error_condition_enum. This means that 00026 // common patters like AnErrorCode == errc::no_such_file_or_directory take 00027 // 4 virtual calls instead of two comparisons. 00028 //===----------------------------------------------------------------------===// 00029 00030 #ifndef LLVM_SUPPORT_ERRC_H 00031 #define LLVM_SUPPORT_ERRC_H 00032 00033 #include <system_error> 00034 00035 namespace llvm { 00036 enum class errc { 00037 argument_list_too_long = int(std::errc::argument_list_too_long), 00038 argument_out_of_domain = int(std::errc::argument_out_of_domain), 00039 bad_address = int(std::errc::bad_address), 00040 bad_file_descriptor = int(std::errc::bad_file_descriptor), 00041 broken_pipe = int(std::errc::broken_pipe), 00042 device_or_resource_busy = int(std::errc::device_or_resource_busy), 00043 directory_not_empty = int(std::errc::directory_not_empty), 00044 executable_format_error = int(std::errc::executable_format_error), 00045 file_exists = int(std::errc::file_exists), 00046 file_too_large = int(std::errc::file_too_large), 00047 filename_too_long = int(std::errc::filename_too_long), 00048 function_not_supported = int(std::errc::function_not_supported), 00049 illegal_byte_sequence = int(std::errc::illegal_byte_sequence), 00050 inappropriate_io_control_operation = 00051 int(std::errc::inappropriate_io_control_operation), 00052 interrupted = int(std::errc::interrupted), 00053 invalid_argument = int(std::errc::invalid_argument), 00054 invalid_seek = int(std::errc::invalid_seek), 00055 io_error = int(std::errc::io_error), 00056 is_a_directory = int(std::errc::is_a_directory), 00057 no_child_process = int(std::errc::no_child_process), 00058 no_lock_available = int(std::errc::no_lock_available), 00059 no_space_on_device = int(std::errc::no_space_on_device), 00060 no_such_device_or_address = int(std::errc::no_such_device_or_address), 00061 no_such_device = int(std::errc::no_such_device), 00062 no_such_file_or_directory = int(std::errc::no_such_file_or_directory), 00063 no_such_process = int(std::errc::no_such_process), 00064 not_a_directory = int(std::errc::not_a_directory), 00065 not_enough_memory = int(std::errc::not_enough_memory), 00066 operation_not_permitted = int(std::errc::operation_not_permitted), 00067 permission_denied = int(std::errc::permission_denied), 00068 read_only_file_system = int(std::errc::read_only_file_system), 00069 resource_deadlock_would_occur = int(std::errc::resource_deadlock_would_occur), 00070 resource_unavailable_try_again = 00071 int(std::errc::resource_unavailable_try_again), 00072 result_out_of_range = int(std::errc::result_out_of_range), 00073 too_many_files_open_in_system = int(std::errc::too_many_files_open_in_system), 00074 too_many_files_open = int(std::errc::too_many_files_open), 00075 too_many_links = int(std::errc::too_many_links) 00076 }; 00077 00078 inline std::error_code make_error_code(errc E) { 00079 return std::error_code(static_cast<int>(E), std::generic_category()); 00080 } 00081 } 00082 00083 namespace std { 00084 template <> struct is_error_code_enum<llvm::errc> : std::true_type {}; 00085 } 00086 #endif