Error.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //===- 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. #ifndef LLVM_TOOLS_LLVM_READOBJ_ERROR_H
  14. #define LLVM_TOOLS_LLVM_READOBJ_ERROR_H
  15. #include <system_error>
  16. namespace llvm {
  17. const std::error_category &readobj_category();
  18. enum class readobj_error {
  19. success = 0,
  20. file_not_found,
  21. unsupported_file_format,
  22. unrecognized_file_format,
  23. unsupported_obj_file_format,
  24. unknown_symbol
  25. };
  26. inline std::error_code make_error_code(readobj_error e) {
  27. return std::error_code(static_cast<int>(e), readobj_category());
  28. }
  29. } // namespace llvm
  30. namespace std {
  31. template <> struct is_error_code_enum<llvm::readobj_error> : std::true_type {};
  32. }
  33. #endif