Error.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. #define LLVMErrorSuccess 0
  23. /**
  24. * Opaque reference to an error instance. Null serves as the 'success' value.
  25. */
  26. typedef struct LLVMOpaqueError *LLVMErrorRef;
  27. /**
  28. * Error type identifier.
  29. */
  30. typedef const void *LLVMErrorTypeId;
  31. /**
  32. * Returns the type id for the given error instance, which must be a failure
  33. * value (i.e. non-null).
  34. */
  35. LLVMErrorTypeId LLVMGetErrorTypeId(LLVMErrorRef Err);
  36. /**
  37. * Dispose of the given error without handling it. This operation consumes the
  38. * error, and the given LLVMErrorRef value is not usable once this call returns.
  39. * Note: This method *only* needs to be called if the error is not being passed
  40. * to some other consuming operation, e.g. LLVMGetErrorMessage.
  41. */
  42. void LLVMConsumeError(LLVMErrorRef Err);
  43. /**
  44. * Returns the given string's error message. This operation consumes the error,
  45. * and the given LLVMErrorRef value is not usable once this call returns.
  46. * The caller is responsible for disposing of the string by calling
  47. * LLVMDisposeErrorMessage.
  48. */
  49. char *LLVMGetErrorMessage(LLVMErrorRef Err);
  50. /**
  51. * Dispose of the given error message.
  52. */
  53. void LLVMDisposeErrorMessage(char *ErrMsg);
  54. /**
  55. * Returns the type id for llvm StringError.
  56. */
  57. LLVMErrorTypeId LLVMGetStringErrorTypeId(void);
  58. /**
  59. * Create a StringError.
  60. */
  61. LLVMErrorRef LLVMCreateStringError(const char *ErrMsg);
  62. LLVM_C_EXTERN_C_END
  63. #endif
  64. #ifdef __GNUC__
  65. #pragma GCC diagnostic pop
  66. #endif