blob: 6a5ba877eb748f8da213b609ff598a8c78de56d9 [file] [log] [blame]
Lang Hames00fb14d2018-08-15 18:42:11 +00001/*===------- llvm-c/Error.h - llvm::Error class C Interface -------*- 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 file defines the C interface to LLVM's Error class. *|
11|* *|
12\*===----------------------------------------------------------------------===*/
13
14#ifndef LLVM_C_ERROR_H
15#define LLVM_C_ERROR_H
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
Lang Hames72d195e2018-09-23 02:09:18 +000021#define LLVMErrorSuccess 0
22
Lang Hames00fb14d2018-08-15 18:42:11 +000023/**
24 * Opaque reference to an error instance. Null serves as the 'success' value.
25 */
26typedef struct LLVMOpaqueError *LLVMErrorRef;
27
28/**
29 * Error type identifier.
30 */
31typedef const void *LLVMErrorTypeId;
32
33/**
34 * Returns the type id for the given error instance, which must be a failure
35 * value (i.e. non-null).
36 */
37LLVMErrorTypeId LLVMGetErrorTypeId(LLVMErrorRef Err);
38
39/**
40 * Dispose of the given error without handling it. This operation consumes the
41 * error, and the given LLVMErrorRef value is not usable once this call returns.
42 * Note: This method *only* needs to be called if the error is not being passed
43 * to some other consuming operation, e.g. LLVMGetErrorMessage.
44 */
45void LLVMConsumeError(LLVMErrorRef Err);
46
47/**
48 * Returns the given string's error message. This operation consumes the error,
49 * and the given LLVMErrorRef value is not usable once this call returns.
50 */
51char *LLVMGetErrorMessage(LLVMErrorRef Err);
52
53/**
54 * Dispose of the given error message.
55 */
56void LLVMDisposeErrorMessage(char *ErrMsg);
57
58/**
59 * Returns the type id for llvm StringError.
60 */
61LLVMErrorTypeId LLVMGetStringErrorTypeId();
62
63#ifdef __cplusplus
64}
65#endif
66
67#endif