OrcError.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--------------- OrcError.h - Orc Error Types ---------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // Define an error category, error codes, and helper utilities for Orc.
  15. //
  16. //===----------------------------------------------------------------------===//
  17. #ifndef LLVM_EXECUTIONENGINE_ORC_SHARED_ORCERROR_H
  18. #define LLVM_EXECUTIONENGINE_ORC_SHARED_ORCERROR_H
  19. #include "llvm/Support/Error.h"
  20. #include "llvm/Support/raw_ostream.h"
  21. #include <string>
  22. #include <system_error>
  23. namespace llvm {
  24. namespace orc {
  25. enum class OrcErrorCode : int {
  26. // RPC Errors
  27. UnknownORCError = 1,
  28. DuplicateDefinition,
  29. JITSymbolNotFound,
  30. RemoteAllocatorDoesNotExist,
  31. RemoteAllocatorIdAlreadyInUse,
  32. RemoteMProtectAddrUnrecognized,
  33. RemoteIndirectStubsOwnerDoesNotExist,
  34. RemoteIndirectStubsOwnerIdAlreadyInUse,
  35. RPCConnectionClosed,
  36. RPCCouldNotNegotiateFunction,
  37. RPCResponseAbandoned,
  38. UnexpectedRPCCall,
  39. UnexpectedRPCResponse,
  40. UnknownErrorCodeFromRemote,
  41. UnknownResourceHandle,
  42. MissingSymbolDefinitions,
  43. UnexpectedSymbolDefinitions,
  44. };
  45. std::error_code orcError(OrcErrorCode ErrCode);
  46. class DuplicateDefinition : public ErrorInfo<DuplicateDefinition> {
  47. public:
  48. static char ID;
  49. DuplicateDefinition(std::string SymbolName);
  50. std::error_code convertToErrorCode() const override;
  51. void log(raw_ostream &OS) const override;
  52. const std::string &getSymbolName() const;
  53. private:
  54. std::string SymbolName;
  55. };
  56. class JITSymbolNotFound : public ErrorInfo<JITSymbolNotFound> {
  57. public:
  58. static char ID;
  59. JITSymbolNotFound(std::string SymbolName);
  60. std::error_code convertToErrorCode() const override;
  61. void log(raw_ostream &OS) const override;
  62. const std::string &getSymbolName() const;
  63. private:
  64. std::string SymbolName;
  65. };
  66. } // End namespace orc.
  67. } // End namespace llvm.
  68. #endif // LLVM_EXECUTIONENGINE_ORC_SHARED_ORCERROR_H
  69. #ifdef __GNUC__
  70. #pragma GCC diagnostic pop
  71. #endif