Error.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. /*===------- llvm-c/Error.h - llvm::Error class C Interface -------*- C -*-===*\
  7. |* *|
  8. |* Part of the LLVM Project, under the Apache License v2.0 with LLVM *|
  9. |* Exceptions. *|
  10. |* See https://llvm.org/LICENSE.txt for license information. *|
  11. |* SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception *|
  12. |* *|
  13. |*===----------------------------------------------------------------------===*|
  14. |* *|
  15. |* This file defines the C interface to LLVM's Error class. *|
  16. |* *|
  17. \*===----------------------------------------------------------------------===*/
  18. #ifndef LLVM_C_ERROR_H
  19. #define LLVM_C_ERROR_H
  20. #include "llvm-c/ExternC.h"
  21. LLVM_C_EXTERN_C_BEGIN
  22. /**
  23. * @defgroup LLVMCError Error Handling
  24. * @ingroup LLVMC
  25. *
  26. * @{
  27. */
  28. #define LLVMErrorSuccess 0
  29. /**
  30. * Opaque reference to an error instance. Null serves as the 'success' value.
  31. */
  32. typedef struct LLVMOpaqueError *LLVMErrorRef;
  33. /**
  34. * Error type identifier.
  35. */
  36. typedef const void *LLVMErrorTypeId;
  37. /**
  38. * Returns the type id for the given error instance, which must be a failure
  39. * value (i.e. non-null).
  40. */
  41. LLVMErrorTypeId LLVMGetErrorTypeId(LLVMErrorRef Err);
  42. /**
  43. * Dispose of the given error without handling it. This operation consumes the
  44. * error, and the given LLVMErrorRef value is not usable once this call returns.
  45. * Note: This method *only* needs to be called if the error is not being passed
  46. * to some other consuming operation, e.g. LLVMGetErrorMessage.
  47. */
  48. void LLVMConsumeError(LLVMErrorRef Err);
  49. /**
  50. * Returns the given string's error message. This operation consumes the error,
  51. * and the given LLVMErrorRef value is not usable once this call returns.
  52. * The caller is responsible for disposing of the string by calling
  53. * LLVMDisposeErrorMessage.
  54. */
  55. char *LLVMGetErrorMessage(LLVMErrorRef Err);
  56. /**
  57. * Dispose of the given error message.
  58. */
  59. void LLVMDisposeErrorMessage(char *ErrMsg);
  60. /**
  61. * Returns the type id for llvm StringError.
  62. */
  63. LLVMErrorTypeId LLVMGetStringErrorTypeId(void);
  64. /**
  65. * Create a StringError.
  66. */
  67. LLVMErrorRef LLVMCreateStringError(const char *ErrMsg);
  68. /**
  69. * @}
  70. */
  71. LLVM_C_EXTERN_C_END
  72. #endif
  73. #ifdef __GNUC__
  74. #pragma GCC diagnostic pop
  75. #endif