Error.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. //===- Error.h - system_error extensions for Object -------------*- 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 Object library.
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_OBJECT_ERROR_H
  14. #define LLVM_OBJECT_ERROR_H
  15. #include <system_error>
  16. namespace llvm {
  17. namespace object {
  18. const std::error_category &object_category();
  19. enum class object_error {
  20. // Error code 0 is absent. Use std::error_code() instead.
  21. arch_not_found = 1,
  22. invalid_file_type,
  23. parse_failed,
  24. unexpected_eof,
  25. string_table_non_null_end,
  26. invalid_section_index,
  27. bitcode_section_not_found,
  28. macho_small_load_command,
  29. macho_load_segment_too_many_sections,
  30. macho_load_segment_too_small,
  31. };
  32. inline std::error_code make_error_code(object_error e) {
  33. return std::error_code(static_cast<int>(e), object_category());
  34. }
  35. } // end namespace object.
  36. } // end namespace llvm.
  37. namespace std {
  38. template <>
  39. struct is_error_code_enum<llvm::object::object_error> : std::true_type {};
  40. }
  41. #endif